Hello,
I know this subject has been discussed before but I could not see a practical solution in those. I need to import 2 columns of data to a dataset tag. Since I am talking about plus 500 rows I am looking for easier way. How this can be done in most practical way?
Thanks
Practical is in the eye of the beholder, but I figure a function would be a good place to start.
Got my paperwork done early, so here's a sample to read from an Excel file
EDIT: Reworked a bit to work with both .xls and .xlsx files
EDIT: Modified to properly cast data types
EDIT: Added handler for formula cell types
EDIT: Added parameters to optionally specify sheet, row, and column numbers
Reading back a file created from my other example:
def excelToDataSet(fileName, hasHeaders = False, sheetNum = 0, firstRow = None, lastRow = None, firstCol = None, lastCol = None):
import org.apac…
One time, or continuously?
I would either manually adjust a CSV file to add the headers our dataset copy/paste format expects:
https://docs.inductiveautomation.com/display/DOC81/system.dataset.fromCSV
Or leave it as a “plain” CSV file and just load and parse it with Python.
1 Like