# Ignition scripting csv import

**URL:** <https://forum.inductiveautomation.com/t/ignition-scripting-csv-import/44561>\
**Category:** Ignition\
**Created:** [March 17, 2021, 6:33am UTC](https://forum.inductiveautomation.com/t/ignition-scripting-csv-import/44561 "2021-03-17T06:33:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![epifanio.tigno](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@epifanio.tigno](https://forum.inductiveautomation.com/u/epifanio.tigno)\
**Post date:** [March 17, 2021, 6:33am UTC](https://forum.inductiveautomation.com/t/ignition-scripting-csv-import/44561/1 "2021-03-17T06:33:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![epifanio.tigno](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@epifanio.tigno](https://forum.inductiveautomation.com/u/epifanio.tigno)\
**Post date:** [March 17, 2021, 6:48am UTC](https://forum.inductiveautomation.com/t/ignition-scripting-csv-import/44561/2 "2021-03-17T06:48:10Z")

</div>

Sorry its good now, i have solve the problem with

if path != None:
