You are viewing limited content. For full access, please sign in.

Question

Question

SDK to create CSV - How to get zero in front of value?

asked on March 15, 2021

Hi all,

 

I'm using SDK (C#) to create and popule a CSV.

The values are picked from tokens.

E.G : token : "A12345B" => value in the CSV : "A12345B"

 

But sometimes, my token's value start with 0 and is only number (eg. 0132456)

At this moment, the value in the CSV is not the right one.

E.G : token : "000123" => value in the CSV : "123" (this should be "000123")

 

My token is a string data.

 

On my script, I'm using Convert.ToString(GetTokenValue("Col1")).

But this is not enought. The value in my CSV is still "123456" and not "0123456"

Need some helps.

Thanks in advance and regards.

0 0

Answer

SELECTED ANSWER
replied on March 15, 2021

Are you checking values in your CSV using Notepad or Excel?

1 0
replied on March 15, 2021

Hi Miruna, Thanks for your help.

You right, I checked CSV using Excel and didn't see the zero but using Notepad, the zero is there.

 

But in Excel, the "0" shouldn't be visible in the formula bar?

 

 

 

 

0 0
replied on March 15, 2021

No, Excel completely reformats the numbers upon loading the file, it's just Excel making assumptions about formatting, and it doesn't have good ways to avoid it when just opening the file.  You can try to avoid it using the Import from Text functionality in Excel instead of opening the CSV file - but then you are creating a different file, not working with the CSV file.

This is a very common frustration with Excel.

3 0
replied on March 15, 2021

One option to get past this is to use the text import wizard in Excel. Basically, go to File -> Open and open the file to go through a little wizard. The last step will let you set the column format to Text for the column(s) that is giving you trouble.

When done, you can save as XLSX. One thing to be aware of is that if the extension is CSV then Excel will just open it. However, if you save with an extension of TXT you can get to the wizard. It's a little annoying so hopefully this is something you only have to do sparingly.

 

2 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.