CSV Column Format Change

Hii Team,

We have a csv file

How do we change column format to no for a csv file

Example

Amt | P_No
668 | 889.82

We have for Excel for changing the column format

For csv files how to we change the column formats

Your suggestions are appreciated

Thanks in advance

Hi,

Can you clarify your requirement?
CSV file doesn’t have information for type in each column.

If you need to handle it as numeric type in datatable after reading, GenerateDataTable with AutodetectTypes option may help you as the following.

Sample20231030-1L.zip (2.6 KB)

Regards,

@NISHITHA

Cav file by default does not store those properties in it…

When reading data into datatable we can cast the column if needed or if all the column values are numeric(that is no blanks or other values are present) then the column will be auto casted to number…if not we can cast the column to number as well by replacing the non numeric values in the column with 0

Cheers

Hi @Yoichi and @Anil_G

We are reading a csv file
Example : dt1

In this file the column are given as general for all

How do we update column format to numeric to the columns in which its required

We will again be writting this data back to csv file

HI,

As we mentioned, csv file doesn’t have coulmn data type. If you have expected result, can you share it?
If you want to change datatype of column in datatable, basically we need to add new column then convert data into it and remove old one.
Or use the above GenerateDataTable activity.

Regards,

Hii @Yoichi

Actually in one of the columns the values that is pasted in Excel csv file is getting printed as below

88929E+12

Instead of

8892929252652665

Hi

I think it’s excel matter.
If you need to display the value in excel, can you try to use Read CSV activity then write the datatable using WriteRangeWorkbook activity?

FYI, the following may also help you.

Regards,

Hi @Yoichi

We are again writing it to csv file

Hi,

If we write the data to excel sheet correctly, we will be able to read it to datatable again correctly.

Or do you want to write datatable to csv without via excel sheet?

Regards,

@NISHITHA

If you open a csv that is written in a specific format the value will be stored in same format…

When you open csv in excelit would generally display in general only…csv does not savethe column formats visually…but when you read ideally youwould get the actual value only

Hope this helps

Cheers

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