# Upload Component

**URL:** <https://forum.inductiveautomation.com/t/upload-component/58096>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 6, 2022, 10:15am UTC](https://forum.inductiveautomation.com/t/upload-component/58096 "2022-04-06T10:15:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iulia\_Bartic](https://avatars.discourse-cdn.com/v4/letter/i/7993a0/32.png) [@Iulia\_Bartic](https://forum.inductiveautomation.com/u/Iulia_Bartic)\
**Post date:** [April 6, 2022, 10:15am UTC](https://forum.inductiveautomation.com/t/upload-component/58096/1 "2022-04-06T10:15:33Z")

</div>

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?

````auto
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!
````

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 6, 2022, 10:41am UTC](https://forum.inductiveautomation.com/t/upload-component/58096/2 "2022-04-06T10:41:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 6, 2022, 10:46am UTC](https://forum.inductiveautomation.com/t/upload-component/58096/3 "2022-04-06T10:46:40Z")

</div>

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](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+File+Upload)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f03b0882504794474b2e27025ef04e8ecddb4577.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 6, 2022, 11:44am UTC](https://forum.inductiveautomation.com/t/upload-component/58096/4 "2022-04-06T11:44:12Z")

</div>

`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.
