Importing CSV file from Server

I’m somewhat new to Ignition and I’m trying to create scripting that will allow me to pull a csv file from a linked server and display the excel table in a power table in Ignition. Does this scripting look correct?:

#Ask the user to find the CSV in the local file system
path = system.file.openFile (“C:\File\formulas.csv”)

#Use readFileAsString to read the contents of the file as a string.
stringData = system.file.readFileAsString (path)

#Convert the string into a dataset
data = system.dataset.fromCSV(stringData)

#Pass the dataset to the data property on the Power Table
event.source.parent.getComponent(‘Power Table’).data = data

It’s a good start, but I’d say, unfortunately, probably not.

system.dataset.fromCSV requires extra info at the top of the file. If the csv file is generated from Excel (this is only based on the mention of it in your post), then that information won’t be there.

One more item I can see is that you will get an error if the system.file.openFile dialog is closed without picking a path.

Thanks for the reply Jordan! No this csv file is being exported by a piece of equipment to a specific folder location.

Looking at the first link, I think I’ll use:

In this example it is assumed that the CSV file being read was a dataset that was previously exported using system.dataset.toCSV:

Specify file path

file_path = “C:\my_dataset.csv”

Read in the file as a string

data_string = system.file.readFileAsString(file_path)

Convert the string to a dataset and store in a variable

data = system.dataset.fromCSV(data_string)

Assign the dataset to a table

event.source.parent.getComponent(‘Table’).data = data

Thanks Jordan