# Export/Import csv questions

**URL:** <https://forum.inductiveautomation.com/t/export-import-csv-questions/10284>\
**Category:** Ignition\
**Created:** [July 28, 2015, 1:38pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284 "2015-07-28T13:38:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [July 28, 2015, 1:38pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/1 "2015-07-28T13:38:28Z")

</div>

I am trying out new things as I learn Ignition/Python and today I was playing around with the .exportCSV command. The command worked fine, and I followed the example found within the user manual, but at the end of the script I believe it’s trying to make it automatically open the document, and I’m getting an error. My code is:

table = event.source.parent.getComponent(‘Table’)  
filePath = system.dataset.exportCSV(“IgnitionTest.csv” , 1, table.data)  
if filePath != None:  
system.net.openURL(“file://”+filePath)

And the error is:

URISyntaxException: Illegal character in authority at index 7: [file://C](file://C):\Users\Alex\Desktop\IgnitionTest.csv

Ignition v7.7.5 (b2015071516)  
Java: Oracle Corporation 1.8.0\_45

I’m not sure what the illegal character in authority at index 7 means? ❓ Any insight to something like this?

Also, I do not see an import command. How would one import a csv file? is there a .importCSV command not listed in the user manual? Thanks in advance for the help! ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 28, 2015, 3:39pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/2 "2015-07-28T15:39:12Z")

</div>

Somewhere along the way, Java’s URI handling changed to something a bit more strict.

Try replacing:

`if filePath != None:
	system.net.openURL("file://"+filePath)`

with this:

`if filePath != None:
   filePath = filePath.replace(' ', '%20')
   filePath = filePath.replace('\\', '/')
   system.net.openURL("file:" + filePath)`

---

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [July 28, 2015, 3:42pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/3 "2015-07-28T15:42:18Z")

</div>

That worked perfectly!!! What exactly is going on with that code? Lots of slashes and quotes going on there. So that’s one question answered! Now, how to import stuff. Any takers?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 28, 2015, 4:04pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/4 "2015-07-28T16:04:51Z")

</div>

> [@alewayhar](#):
>
> What exactly is going on with that code? Lots of slashes and quotes going on there.

Spaces and backslashes are not supported characters for a URI. So the spaces get replaced by %20, the Hex ASCII equivalent. You may have noticed it used in your web browser address bar.

Backslashes are bit more complex. in Python, a backslash is used for special characters. Example, '\n' is a newline. If you actually need a backslash character, you would use a double-backslash. How's that for mud in the water? 😆

* * *

For handling CSV, take a look at [this thread](https://inductiveautomation.com/forum/viewtopic.php?f=92&t=14058&p=51261&hilit=csv#p51261)

---

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [July 28, 2015, 7:36pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/5 "2015-07-28T19:36:14Z")

</div>

Ok, I think the spaces and black slashes issues are pretty clear ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")

While that CSV help forum is helpful I think it left me even more confused ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:") I was wanting to use the .readFileAsString command and it keeps returning the error:

Traceback (most recent call last):

File “event:actionPerformed”, line 4, in

IOError: File ‘C:\Users\Alex\Desktop\Tags’ doesn’t exist or isn’t a file.

The code I’m using in this application for this button is:

fileName=event.source.parent.getComponent(‘Text Field’).text  
path = system.file.openFile

textarea= system.file.readFileAsString(“C:\Users\Alex\Desktop\”+fileName)

event.source.parent.getComponent(‘Text Area’).text = textarea

Am I way off the reservation with this or am I pretty close, just missing it by that much? 😆 The help so far has been astounding and greatly appreciated!

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 28, 2015, 7:54pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/6 "2015-07-28T19:54:46Z")

</div>

Let's start here:

> [@alewayhar](#):
>
> IOError: File 'C:\Users\Alex\Desktop\Tags' doesn't exist or isn't a file.

Is the filename just 'Tags'? You likely have an extension on the filename, like 'Tags.csv'. If so, that's where the issue is. 🙂

---

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [July 28, 2015, 8:12pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/7 "2015-07-28T20:12:00Z")

</div>

Accolades all around! That solved it good sir!!! ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:") ![:thumb_right:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2026e28c0c425034352c1b75807edf956adc75f4.gif ":thumb\_right:")

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 28, 2015, 8:13pm UTC](https://forum.inductiveautomation.com/t/export-import-csv-questions/10284/8 "2015-07-28T20:13:10Z")

</div>

Glad I could help, Alex!
