Hello
In this script below in CSV import in forum of inductive automation, It throws and error when i cancel the dialog box. How can we remove the when the cancel is pressed?
# Import Python's built-in csv library.
import csv
# Ask the user to find the CSV in the local file system.
path = system. file .openFile( "csv" )
# Create a reader object that will iterate over the lines of a CSV.
# We're using Python's built-in open() function to open the file.
csvData = csv.reader( open (path))
# Create a List of strings to use as a header for the dataset. Note that the number
# of headers must match the number of columns in the CSV, otherwise an error will occur.
# The simplest approach would be to use next() to read the first line in the file, and
# store that at the header.
header = csvData. next ()
# Create a dataset with the header and the rest of our CSV.
dataset = system.dataset.toDataSet(header , list (csvData))
# Store it into the table.
event.source.parent.getComponent( 'Power Table' ).data = dataset
heres the error:
Traceback (most recent call last):
File “event:actionPerformed”, line 7, in
java.lang.ClassCastException: class org.python.core.PyNone cannot be cast to class org.python.core.PyString (org.python.core.PyNone and org.python.core.PyString are in unnamed module of loader java.net.URLClassLoader @19cd9d83)
java.lang.ClassCastException: java.lang.ClassCastException: class org.python.core.PyNone cannot be cast to class org.python.core.PyString (org.python.core.PyNone and org.python.core.PyString are in unnamed module of loader java.net.URLClassLoader @19cd9d83)
caused by ClassCastException: class org.python.core.PyNone cannot be cast to class org.python.core.PyString (org.python.core.PyNone and org.python.core.PyString are in unnamed module of loader java.net.URLClassLoader @19cd9d83)
Ignition v8.1.1 (b2020120808)
Java: Azul Systems, Inc. 11.0.7