Is there a way to Import a .CSV file into a dataset? I would like to use the exportCSV script, modify my dataset in Excel, then import the updated .CSV file into a dataset.
Thanks
Is there a way to Import a .CSV file into a dataset? I would like to use the exportCSV script, modify my dataset in Excel, then import the updated .CSV file into a dataset.
Thanks
Yes, you can! You can use the system.dataset.fromCSV function to pull in a CSV with something like this:path = system.file.openFile("csv")
if path != None:
csv = system.file.readFileAsString(path)
event.source.parent.getComponent('Table').data = system.dataset.fromCSV(csv)
The only issue with that is it expects a certain format as a header."#NAMES"
"Index","Name","Value"
"#TYPES"
"I","str","D"
"#ROWS","4"
"81","Test Row 4","83.01864192210952"
"54","Test Row 4","95.4011884590994"
"68","Test Row 16","60.654079821521954"
"65","Test Row 2","53.594277189481744"
Otherwise, you can use the system.file.readFileAsString() directly to get the text of a CSV and parse through it into a dataset however you’d like.