cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Convert CSV Column data type to string

Hi,

 

I have successfully parse a json and converted it to a csv file and a text file (.txt). The problem is, there are two columns that are being converted as integer when i open the csv file in excel. 

 

In parse JSON, the types are already "string".

jsdom_3-1603195633897.png

 

 

 

As you can see on the image below, Seq 1 & Seq 2 are of type string

jsdom_0-1603195287819.png

But when i open the csv file in excel , those columns are being treated as integer (which is not OK. )

 

In here, the Seq 1 & Seq 2 are automatically right aligned which means they are treated as integer when i open the file in excel. Unlike Seq3, which is left aligned and is being treated as string.

jsdom_1-1603195469429.png

 

I tried to convert the column to String but i am not sure if i am doing this right. The flow runs, but i still have the same problem.

jsdom_2-1603195580931.png

 

Any help is much appreciated.

 

Kind regards,

 

jsdom

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

You need to use the Excel tab trick as discussed in this post:

 

https://superuser.com/questions/318420/formatting-a-comma-delimited-csv-to-force-excel-to-interpret-...

 

I built a flow and tested it with data like yours and it works well:

 

ExcelToText.png

 

Excel interprets it correctly:

 

ExcelToText2.png

 

Note that the initialize variable step literally has a tab copied and pasted into it. So the code looks like this:

{
    "inputs": {
        "variables": [
            {
                "name": "charTab",
                "type": "string",
                "value": "\t"
            }
        ]
    }
}

 

Hope this helps.

View solution in original post

5 REPLIES 5
Highlighted
Dual Super User III
Dual Super User III

In the Create CSV action add double quotes around those fields that are being interpreted as numbers.  That way when you open the CSV in Excel they will be implicitly read as strings.  The problem is that the CSV doesn't include any type information.  It assumes the data type of each entry based on the entry itself.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Frequent Visitor

@Pstork1 

 

Thanks! But unfortunately, those columns have double quotes now in them. I also tried to put single quote in the beginning of create csv, but the single quote appeared too. I also tried putting and equal sign, and equal + single quote.. but still the same. 

 

jsdom_0-1603201058043.png

 

Kind regards,

 

 

 

Highlighted
Memorable Member
Memorable Member

You need to use the Excel tab trick as discussed in this post:

 

https://superuser.com/questions/318420/formatting-a-comma-delimited-csv-to-force-excel-to-interpret-...

 

I built a flow and tested it with data like yours and it works well:

 

ExcelToText.png

 

Excel interprets it correctly:

 

ExcelToText2.png

 

Note that the initialize variable step literally has a tab copied and pasted into it. So the code looks like this:

{
    "inputs": {
        "variables": [
            {
                "name": "charTab",
                "type": "string",
                "value": "\t"
            }
        ]
    }
}

 

Hope this helps.

View solution in original post

Highlighted
Frequent Visitor

@Paulie78 

 

Thank you so much! That really helps. 

 

jsdom_0-1603203389164.png

 

Kind regards,

 

Highlighted

@jsdom No worries, glad you got it sorted.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (2,384)