# How could import CSV in perspective through Ignition / ignition Edge

**URL:** <https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [March 17, 2023, 9:09pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259 "2023-03-17T21:09:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chang\_Shi](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@Chang\_Shi](https://forum.inductiveautomation.com/u/Chang_Shi)\
**Post date:** [March 17, 2023, 9:09pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/1 "2023-03-17T21:09:18Z")

</div>

We only want use perspective to do it. How could import csv file in perspective through Ignition? Any suggestions?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 17, 2023, 9:20pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/2 "2023-03-17T21:20:20Z")

</div>

If you want to import using perspective, you would need to use a file upload component, which requires the user to select and upload a file.

Write a script in the `onFileRecieved` handler to either parse the data immediately or save the file somewhere on the gateway and signal Ignition to parse the data in the file. (You could use a message handler on the gateway that passes the saved location of the file, let the data processing run in the background independently of the perspective session)

---

<div class="post-metadata">

**Author:** ![Chang\_Shi](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@Chang\_Shi](https://forum.inductiveautomation.com/u/Chang_Shi)\
**Post date:** [March 18, 2023, 12:01am UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/3 "2023-03-18T00:01:25Z")

</div>

Thank your for quick replying. I tried to use the File Uploaded component in Perspective through ignition. Following by [Download and Upload Files - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Download+and+Upload+Files)  
it got error message. Another question will be if uploaded the file successfully, where could find the file? on the gateway or in the ignition designer? Addiction question, for the txt file, do you have format for it?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 18, 2023, 12:32am UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/4 "2023-03-18T00:32:24Z")

</div>

What was the error? Copy the entire error into a pre-formatted text section in your reply (the `</>` button above the text field)

If you go the route of saving a copy of the uploaded file, it will be on the gateway computer/device. Perspective runs on the gateway so that's where everything ends up.

The example given is uploading the file to a database for storage, but as a file. If you want to parse the data as a CSV, then something along the lines of this should work:

```auto
import csv

csvFileData = event.file.getBytes()
csvData = csv.reader(csvFileData)

headers = csvData.next()
dataset = system.dataset.toDataSet(headers, list(csvData))

system.tag.writeBlocking(["[default]path/to/dataset/tag"], [dataset])

```

That will attempt to read the file bytes as a CSV and store the data in a dataset tag that can be retrieved in a different script for uploading to a database.

If your csv headers match your db table column names then it should be a pretty straightforward insert statement. If the headers don't match the column names, then you need to write a script to map the columns accordingly.

> [@Chang\_Shi](#):
>
> Addiction question, for the txt file, do you have format for it?

I'm not sure what you mean by this, its a .txt. file, so that would be its format. If you are talking about the `supportedFileTypes` property of the file upload component, you would probably want `"csv"` and `"txt"` as items in the array

---

<div class="post-metadata">

**Author:** ![Chang\_Shi](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@Chang\_Shi](https://forum.inductiveautomation.com/u/Chang_Shi)\
**Post date:** [March 22, 2023, 5:09pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/5 "2023-03-22T17:09:30Z")

</div>

Thank you for replying. Quick Question for you. Regarding your example code, which type of tag are you created? I figure out the txt file issue. Thank you.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 22, 2023, 5:36pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/6 "2023-03-22T17:36:39Z")

</div>

Should be a memory tag that is set to dataset type.

---

<div class="post-metadata">

**Author:** ![Chang\_Shi](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@Chang\_Shi](https://forum.inductiveautomation.com/u/Chang_Shi)\
**Post date:** [March 22, 2023, 5:38pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/7 "2023-03-22T17:38:41Z")

</div>

ok. Regarding the tag, I have another question. Is possible to create own opc tag, and saving those data into own opc tag.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 22, 2023, 5:43pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/8 "2023-03-22T17:43:23Z")

</div>

You can make an OPC tag with a dataset type, you would just need to make sure whatever device that you are talking to knows how to interpret a dataset.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 22, 2023, 5:47pm UTC](https://forum.inductiveautomation.com/t/how-could-import-csv-in-perspective-through-ignition-ignition-edge/71259/9 "2023-03-22T17:47:07Z")

</div>

> [@Chang\_Shi](#):
>
> create own opc tag

OPC tags are expected to point at an OPC item in an OPC connection. If you just want a tag to remember a value for you for other reasons, use a **memory** tag.
