Upload Component

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!

It is not clear if you are aware that the script will run on the server, not on the client PC. The C: drive will be that of the server.

Am I missing something?

Yeah this seems weird.

Also if you use the upload component you dont need to open the file again, you already have the data
https://docs.inductiveautomation.com/display/DOC81/Perspective+-+File+Upload
image

event.file.name is informational. You have no access whatsoever to the origin machine’s filesystem. You may use event.file.copyTo() to place the file content somewhere in the gateway, or you may use event.file.getBytes() or .getString() to work with the file content directly.