# \[SOLVED\] How to import a CSV file with a unique delimiter character

**URL:** <https://forum.inductiveautomation.com/t/solved-how-to-import-a-csv-file-with-a-unique-delimiter-character/38035>\
**Category:** Ignition\
**Tags:** ignition80, vision, scripting\
**Created:** [August 24, 2020, 7:16pm UTC](https://forum.inductiveautomation.com/t/solved-how-to-import-a-csv-file-with-a-unique-delimiter-character/38035 "2020-08-24T19:16:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 24, 2020, 7:16pm UTC](https://forum.inductiveautomation.com/t/solved-how-to-import-a-csv-file-with-a-unique-delimiter-character/38035/1 "2020-08-24T19:16:01Z")

</div>

Good afternoon,

I have a CSV file delimited with a pipe | character. How would I go about importing this into a powertable?  
Currently this code below works for a comma delimited CSV file:

```
import csv

path = system.file.openFile("csv")
csvData = csv.reader(open(path)) 
	
header = csvData.next()
data = system.dataset.toDataSet(header, list(csvData))

return data
```

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 24, 2020, 7:22pm UTC](https://forum.inductiveautomation.com/t/solved-how-to-import-a-csv-file-with-a-unique-delimiter-character/38035/2 "2020-08-24T19:22:54Z")

</div>

I just use .split on the line and then parse it that way.

```auto
import os.path
path = system.file.openFile("csv")
myfile = open(path, "r")
for line in myfile:
    sline = line.split('|')
    var1 = sline[1]
    var2 = sline[2]

```

etc.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 24, 2020, 7:24pm UTC](https://forum.inductiveautomation.com/t/solved-how-to-import-a-csv-file-with-a-unique-delimiter-character/38035/3 "2020-08-24T19:24:41Z")

</div>

You beat me to a solution… I googled this moments after posting lol.

[https://docs.python.org/3/library/csv.html#csv-fmt-params](https://docs.python.org/3/library/csv.html#csv-fmt-params)

```
import csv
	
path = system.file.openFile("csv")
csvData = csv.reader(open(path), delimiter='|') 
	
header = csvData.next()
data = system.dataset.toDataSet(header, list(csvData))

return data
```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 24, 2020, 8:01pm UTC](https://forum.inductiveautomation.com/t/solved-how-to-import-a-csv-file-with-a-unique-delimiter-character/38035/4 "2020-08-24T20:01:51Z")

</div>

Just be aware that the ‘naive’ `split()` solution will fail if you have something like this:  
`"row"|"a weird row containing | the delimiter"|"another row"`  
Adjusting the csv reader is probably ‘safer’ for potential malformed input like that (_if_ it’s a risk).

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 25, 2020, 12:36pm UTC](https://forum.inductiveautomation.com/t/solved-how-to-import-a-csv-file-with-a-unique-delimiter-character/38035/5 "2020-08-25T12:36:18Z")

</div>

We have homegrown text files from a previous HMI system that are | delimited and consistent.  
🙂
