Then I have a button to export table data to CSV file.
When the export is done and I look at the CSV file, I see that numbers in last column doesn’t have comma as decimal separator, but dot:
Is there anything that I can set or change in settings somewhere…? Because I need my decimal numbers in CSV file to have comma for decimal separator and dot for thousand separator.
I’ve tried to change setting in Windows control panel for Region and Language, but it seems that Ignition (or Java?) does not take, what’s in there. After every change I made, I restarted the PC, but no luck. I always get dot for decimal separator…
So this is indeed a bug and I've added it to our system. Unfortunately it's not going to make it into the 7.5.6 release so I'm not sure exactly when it will be available. Probably a 7.5.7beta release sometime after 7.5.6 is officially made available.
Thank you. But what can I do until then?
I must export (automatically) some CSV’s every night, so that people can next day import them in Excel and evaluate them…
It might be a hackish solution, but since your data doesn’t contain periods in the first place maybe do something like this:
filename = "mydata.csv"
# capture the table and do the export
table = event.source.parent.getComponent("Table")
system.dataset.exportCSV(filename, 1, table.data)
# sanity check to make sure the file we exported was created
path = system.file.openFile(filename)
if path != None:
contents = system.file.readFileAsString(path)
fixed = contents.replace('.', ',') # simple replacement of periods with commas
system.file.writeFile(filename, fixed, 0)
Writing a script will be your best option. You can take the approach offered up by @Greg.Buehler or as opposed to exporting it first just loop through the dataset and then create a list of your dataset rows, one entry per row. Then you could use the string.join(list) function of python to join the list into one large comma separated string that you could write to a file. Here is an ugly example of a possible loop:
Yes, you can export the data without prompting the user. You just can’t use the function:system.dataset.exportCSVsince it is built-in to prompt the user. You need to do something like this:data = event.source.parent.getComponent("Table").data
csv = system.dataset.toCSV(data, 1)
system.file.writeFile("C:\\Path\\To\\File.csv", csv)
Which function did you use? The function that was fixed was the system.dataset.exportCSV(). If you used the system.dataset.toCSV() there still may be a locale issue with that function.
Now I’m confused.
I’m using system.dataset.exportCSV(). When I tried 3 days ago (on the same computer like today), it didn’t work (periods for decimal). When I tried now, it’s OK (commas for decimal)!?
And I didn’t upgrade java or Ignition or anything…
Ok, I'll submit another ticket for this. Your best option right now is to do it through scripting using one of the above examples until this gets resolved. Thanks for letting us know about this.