Csv Output Issue - Don’t want to round off value in CSV file

Hi team,

I am having values in Data table but after writing the values in the csv or excel he values are getting rounding off even tried to change the column formats in the excel as text and number not working

Input Datable before writing into csv -

account_id email_address
8255110500129566 abc@test.org
8255707087262163 test1@avc.com
8255909010804414 test2@gmail.com

After writing into csv or excel file the values are getting round off
8255110500129560 abc@test.org
8255707087262160 test1@avc.com
8255909010804410 test2@gmail.com

Regards,
naveen

Hi,

How did you check the value?
Can you try to check csv file using text editor?

I guess it’s excel reading matter.

Regards,

1 Like

Hi @Yoichi

Thank you for the response

Yes, facing issue after writing the data into excel
I have added ’ for each account number in data table before writing into excel('8255110500129566) in that time its working as expected but i don’t want to ’ to display in csv file

Is there any way to avoid this issue , tried all possible ways

Hi,

For now, can you try to use Write Range Workbook activity as the following?

image

Regards,

I need the output file as csv only

Hi

Sorry but what is your input and expected output? Is your input Excel? If so, please can you try to set cell format as text? Or can you share your input?

Regards,

The input is Datable which is coming from database and output is csv file

Hi,

In the CSV file, data is correctly stored like 8255110500129566, right?

What is your current problem?
To write date from the csv to excel? If so, can you try WriteRangeWorkbook or WriteCellWorkbook OR use FormatCell activity in advance as the following?

Regards,

I am getting input form database like below as correct format

account_id email_address
8255110500129566 abc@test.org
8255707087262163 test1@avc.com
8255909010804414 test2@gmail.com

But after writing same database input into csv file , in the csv file the data is displaying like this , which is not correct(write csv)

After writing into csv or excel file the values are getting round off
8255110500129560 abc@test.org
8255707087262160 test1@avc.com
8255909010804410 test2@gmail.com

Hi,

To isolate cause, can you try to set Breakpoint at the WriteCSV and run debug mode?
Workflow will stop there, then check content of datatable at Locals panel if correct value or not.

Regards,

1 Like

Yes, i have checked the output is coming correct only after writing into csv values are getting round off

Seems strange… In my environment, the above data is written correctly into csv file as the following.

image

Did you check it by text editor?

Regards,

I am not sure what is the issue, when i try to open the output file with note pad , the values are showing correctly but while trying to open with excel not showing correctly

CSV output

image

HI,

From the image, the data is correctly stored in the CSV

As i mentioned, it’s excel reading matter. It’s necessary to handle data as text in the sheet.

For now, can you try to open the csv file via FIle-Open menu?
Then Text Import Wizard will be launch, and set comma as demiliter and Text as dataformat?

Or write csv to excel using WriteRangeWorkbook, then check the xlsx file.

image

Regards,

can you please check the datatype of the “account_id” column when it was first created in datatable(at source)?
i think it is integer/decimal type column because of which when it writes back to excel it causes default rounding off of data
Possible solutions:
1.Change the column type into a string type column when you are first defining the datatable, and while doing add datarow use .tostring while entering “account_id” column’s value
2.If the source datatable is coming from a different source and you dont have control of using build datatable, then add a new datacolumn say “str_account_id” of string type, and use for each row to populate the value of this column

CurrentRow("str_account_id")=CurrentRow("account_id").ToString

3.optimal approach use datacolumn expression to set a formula for the new column in this way you will not need a for looping

DT.Columns("str_account_id").Expression="CONVERT([account_id], 'System.String')"

I hope this helps :slight_smile: