Hello!
I want to import an .csv file with upload component in Perspective and import it automatically in sql.
I managed to get something except that it has a small drawback and that is the location of the imported file is not variable.
Is there any way to get the path file the same as with filename or is there any possibility to import an excel/csv with this component?
import csv
filename = event.file.name
file = open("C:\Users\iulia.bartic\Desktop\EXPORT" + "\\" + filename, 'r') #file location + file name get from upload component
readerCsv = csv.reader(file)
headerCsv = ["ID" , "VALUE"]
data = system.dataset.toDataSet(headerCsv, list(readerCsv))
for i in range (data.rowCount):
if i != 0:
id = data.getValueAt(i, "ID")
value = data.getValueAt(i, "VALUE")
system.db.runUpdateQuery("INSERT INTO [UPLOAD]([ID],[VALUE]) VALUES ( %i,'%s')" % (int(id), value), 'Ignition_Dashboards')
```
Thank you!
Have a nice day!