[Write CSV] Set format as Text

Hi. Just want to check whether is there a way to set whatever you write inside the CSV to be Text formatting?
Currently, I’m using data scraping to collect data from SAP then write into CSV. However, all cells are formatted as number. It results in this → 7.00708E+12
Is there a way to change it?

Hi,

The following expression reutuns 7007080000000.

Double.Parse("7.00708E+12").ToString

However, is it correct value which you expect? If not, it might be needed to extract actual value before converted such style.

Regards,

Yes I wanted it to print “7007080000000” instead of “7.00708E+12” inside the CSV.
But there are different thousand of numbers taken from somewhere using Data Scraping then write into CSV. How to use assign in this case?
Currently inside the datatable:
Column 1 (Number)
Column 2 (String)

Write to CVS:
Column 1 (String)
Column 2 (String)

Convert all values inside the datatable into string variables.

Hi,

Can you try the following sample?

dtNew = dt.AsEnumerable.Select(Function(r) dtNew.LoadDataRow({Double.Parse(r(0).ToString).ToString,r(1)},False)).CopyToDataTable

Sample20220113-2.zip (2.7 KB)

Please check result using text editor (such as notepad).

Regards,

Hi. I think I didn’t make it clear. I have a CSV file. Inside the CSV, cells type format are General.

image

I want it to be like this inside the CSV file.

image

I tried Balareva.Excel.Activity → Change cells type. But I think it only works for xlsx format. it does run but nothing changes.

Hi,

It seems excel format matter. In the above sample workflow, the result csv has data like 7007080000000 and doesn’t have format information.
Can you try to convert csv to xlsx using UseExcelFile and SaveExcelFileAs, then convert each cell to numeric type?

img20220114-6

Regards,

1 Like

Thank you very much!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.