CSV Read Error - ValueError: CSV invalid format: expected #NAMES on line 1

Trying to read a CSV file to do some logic on it in the designer scripting console. I have this as my script -

csv_path = "C:\\Users\\bkarabinchak\\Desktop\\toRead.csv"
csv_string = system.file.readFileAsString(csv_path)
csv_file = system.dataset.fromCSV(csv_string)

and am getting the following error

Traceback (most recent call last):
  File "<input>", line 3, in <module>
ValueError: CSV invalid format: expected #NAMES on line 1

Here is my CSV file which seems very run of the mill so I am not sure what is going wrong - toRead.csv (2.0 KB)

How can I read this csv file?

Your CSV is not formatted correctly for system.dataset.fromCSV().

Here’s the format:
https://docs.inductiveautomation.com/display/DOC81/system.dataset.fromCSV

2 Likes

Boy do I have egg on my face telling my coworkers to read the documentation for problems and missing this one. Thanks.

2 Likes