# Importing the CSV file in Ignition Perspective

**URL:** <https://forum.inductiveautomation.com/t/importing-the-csv-file-in-ignition-perspective/65986>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [November 2, 2022, 10:21am UTC](https://forum.inductiveautomation.com/t/importing-the-csv-file-in-ignition-perspective/65986 "2022-11-02T10:21:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divya\_Chorge](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@Divya\_Chorge](https://forum.inductiveautomation.com/u/Divya_Chorge)\
**Post date:** [November 2, 2022, 10:21am UTC](https://forum.inductiveautomation.com/t/importing-the-csv-file-in-ignition-perspective/65986/1 "2022-11-02T10:21:41Z")

</div>

How to import or read the CSV file in Ignition Perspective.  
I am using the below code for CSV file but I am getting the error as "AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'openFile' "  
Is there any way for it?

```
    import csv
path = system.file.openFile("csv")
csvData = csv.reader(open(path))
header = csvData.next()
dataset = system.dataset.toDataSet(header ,list(csvData))
event.source.parent.getComponent('Table').data = dataset

```

---

<div class="post-metadata">

**Author:** ![Frederic\_Avet](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@Frederic\_Avet](https://forum.inductiveautomation.com/u/Frederic_Avet)\
**Post date:** [November 2, 2022, 10:50am UTC](https://forum.inductiveautomation.com/t/importing-the-csv-file-in-ignition-perspective/65986/2 "2022-11-02T10:50:43Z")

</div>

I'm using the following code to open a CSV and execute a script to add tags

```auto
import csv	#import the python csv library
# Script tools to open csv file and import tags of specified UDT Type

# Open csv file through file selector
def openFile():
	filePath = system.file.openFile("csv","%user%")
	csvFile = open(filePath, 'r')
	reader = csv.DictReader(csvFile, delimiter = ';')
	line_count = 0
	print reader.fieldnames
	for row in reader:
		#print row
		addTag( row )

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 2, 2022, 11:19am UTC](https://forum.inductiveautomation.com/t/importing-the-csv-file-in-ignition-perspective/65986/3 "2022-11-02T11:19:29Z")

</div>

From a Perspective session, this should be closer to what you're looking for.

> [@Perspective onFileReceived - CSV](https://forum.inductiveautomation.com/t/perspective-onfilereceived-csv/39893/3):
>
> Awesome - Felt I was close just couldn’t find what I needed. Should have asked sooner slight_smile FYI for future readers below was the updated script to make it work from perspective from StringIO import StringIO import csv fileContents = event.file.getString("UTF-8") reader = csv.DictReader(StringIO(fileContents)) for row in reader: system.perspective.print(row) Thanks again!

---

<div class="post-metadata">

**Author:** ![Divya\_Chorge](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@Divya\_Chorge](https://forum.inductiveautomation.com/u/Divya_Chorge)\
**Post date:** [November 2, 2022, 11:49am UTC](https://forum.inductiveautomation.com/t/importing-the-csv-file-in-ignition-perspective/65986/4 "2022-11-02T11:49:04Z")

</div>

Hi Frederic\_Avet,  
I have used your script which you provided above but I am not able to browse the CSV file, it is not giving any error also.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [November 2, 2022, 11:56am UTC](https://forum.inductiveautomation.com/t/importing-the-csv-file-in-ignition-perspective/65986/5 "2022-11-02T11:56:09Z")

</div>

Remember that, Perspective doesn't have direct access to the client machines file system. You will need to use the file upload component to get the file.

In the post that @JordanCClark linked to, the OP was using the script in the onFileRecieved event of this component.
