Dataset to CSV without quotes

Hi all :slightly_smiling_face:

We are running a query against a table in our database, and it returns a dataset with two columns ( name , value ).
The dataset is converted to a CSV by:

csv = system.dataset.toCSV(ds,1)

We then save the CSV file to our local disk.

If we open the CSV in notepad, there are quotation marks around all names and values:

#NAMES
“Tag”,“hour”
#TYPES
“str”,“D”
#ROWS”,“196”
“test1”,“0.7791961111111098”
“test2”,“0.7791961111111098”
“test3”,“0.7791961111111098”
.
.
.

Anyone knows how to export a dataset to a CSV file without all the quotations?

Ignition version 7.9.10

Seems like this small snippet of code did it:

csv = system.dataset.toCSV(ds,1)
filename = "test.csv"
system.file.writeFile(filename,csv)

with open('test.csv','rt') as f:
	data = f.read()
new_data = data.replace('"','')

filePath = "newCSV.csv"
system.file.writeFile(filePath, new_data)

:cowboy_hat_face:

Why do you want to remove quotes? Wont this will break many strings?..

A third party company that is using the csv-file asked us if we could get rid of the quotations, since their system were not able to interpret the original csv with quotations.
So we adjusted the script to save both the original csv with quotations, and a new csv without the quotations. Now they can use either of them in their attempt to gather the csv-data :upside_down_face:

yikes xd welh if you save both then it is their problem i guess lol

yikes indeed :laughing:
Wishing them the best of luck… :grinning_face_with_smiling_eyes:

2 Likes