# Convert unicode from API Endpoint (csv) to csv or jason or pydataset

**URL:** <https://forum.inductiveautomation.com/t/convert-unicode-from-api-endpoint-csv-to-csv-or-jason-or-pydataset/72721>\
**Category:** General Discussion\
**Created:** [April 20, 2023, 5:23pm UTC](https://forum.inductiveautomation.com/t/convert-unicode-from-api-endpoint-csv-to-csv-or-jason-or-pydataset/72721 "2023-04-20T17:23:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh\_Madapathi](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@Mahesh\_Madapathi](https://forum.inductiveautomation.com/u/Mahesh_Madapathi)\
**Post date:** [April 20, 2023, 5:23pm UTC](https://forum.inductiveautomation.com/t/convert-unicode-from-api-endpoint-csv-to-csv-or-jason-or-pydataset/72721/1 "2023-04-20T17:23:54Z")

</div>

I made a HTTP request to a CSV API Endpoint. I used  
response = system.net.httpGet(url,'','','','',header)

and the response received is of 'unicode type.

> > > type(response)  
> > > \<type 'unicode'\>

How can I convert it to a dataset?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 20, 2023, 5:28pm UTC](https://forum.inductiveautomation.com/t/convert-unicode-from-api-endpoint-csv-to-csv-or-jason-or-pydataset/72721/2 "2023-04-20T17:28:42Z")

</div>

It would be helpful to see what the response actually is.

But if it's a CSV, I would imagine it's just a long string with values separated by ',' and '\n' or similar to denote end of lines.

So you could split on '\n' to get the lines and then split on ',' to get the values.

But this is pure speculation unless we can see what the response actually is.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 20, 2023, 5:30pm UTC](https://forum.inductiveautomation.com/t/convert-unicode-from-api-endpoint-csv-to-csv-or-jason-or-pydataset/72721/3 "2023-04-20T17:30:29Z")

</div>

You can use Python's `csv` module to parse the CSV, then construct your dataset yourself:

> [@Perspective onFileReceived - CSV](https://forum.inductiveautomation.com/t/perspective-onfilereceived-csv/39893/2):
>
> If you want to use Python’s built-in csv module, you need to construct a file-like object to pass to the reader. Luckily, Python also predicted the idea of interpreting a string in memory as a ‘file-like’ object, so the StringIO module already exists. What you want is probably something like this: from StringIO import StringIO fileContents = event.file.getString("UTF-8") reader = csv.DictReader(StringIO(fileContents)) for row in reader: print row

[https://docs.inductiveautomation.com/display/DOC81/system.dataset.toDataSet](https://docs.inductiveautomation.com/display/DOC81/system.dataset.toDataSet)

---

<div class="post-metadata">

**Author:** ![Mahesh\_Madapathi](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@Mahesh\_Madapathi](https://forum.inductiveautomation.com/u/Mahesh_Madapathi)\
**Post date:** [April 20, 2023, 6:14pm UTC](https://forum.inductiveautomation.com/t/convert-unicode-from-api-endpoint-csv-to-csv-or-jason-or-pydataset/72721/4 "2023-04-20T18:14:57Z")

</div>

It started off well, but I see this error

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/95fa25e72e962a5ed47416d0400b46abdcf3b5fd.png)

---

<div class="post-metadata">

**Author:** ![Mahesh\_Madapathi](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@Mahesh\_Madapathi](https://forum.inductiveautomation.com/u/Mahesh_Madapathi)\
**Post date:** [April 20, 2023, 6:26pm UTC](https://forum.inductiveautomation.com/t/convert-unicode-from-api-endpoint-csv-to-csv-or-jason-or-pydataset/72721/5 "2023-04-20T18:26:06Z")

</div>

this helped.  
No errors now.

[Csv file import - Error: Cannot create PyString with non-byte value - #3 by PGriffith](https://forum.inductiveautomation.com/t/csv-file-import-error-cannot-create-pystring-with-non-byte-value/47143/3)

I think I am set for now. I just need to convert it to dataset.
