Why Python? Why not Python? Everything written in StarBasic can be written in Python as well. However, it makes no difference with simple macro stuff, since all macro code talks to the exact same API. We still don't know which software we are talking about. And we still don't know anything about the particular flavor of csv you try to import.
StarBasic routine, translated line by line into Python. Pass over system paths instead of URL paths.
StarBasic routine, translated line by line into Python. Pass over system paths instead of URL paths.
Code:
import shutil, unodef ImportCSV(conn, sPathName, sTextFile,sDBPath, sTextTable, sView, sDataTable):'''Replace sTextFile in sDBPath with file sPathName while sTextTable is disconnected. Then use sView to insert into sDataTable'''sqlSET ='SET TABLE "'+ sTextTable + "' SOURCE 'oStmt1 = conn.prepareStatement(sqlSET + "OFF")oStmt2 = conn.prepareStatement(sqlSET + "ON")sqlINSERT = 'INSERT INTO "'+ sDataTable +'" (SELECT "'+ sView +'".* FROM "'+ sView +'")''print sqlINSERToStmt3 = conn.prepareStatement(sqlINSERT)b = oStmt1.execute()shutil.copy(sPathName, sDBPath & sTextFileb = oStmt2.execute()b = oStmt3.executeUpdate()return b
Statistics: Posted by Villeroy — Thu Sep 19, 2024 7:29 pm