Convert datatable general value to number

Hi all,

I’m having an issue formating a data column as numeral with one decimal digit.
The datatable has no headers and I need to convert the column index 3, which is as general now, to number.

The point is that I don’t want to use Excel activities but instead manipulate the data directly in the data table. Is it possible?

Best regards and many thanks,
Roberto Piccolli

Hi

Check with this thread for your scenario

Cheers @roberto.piccolli

Hi @roberto.piccolli

Yes its possible and can you share the input and expected out

Yes in general possible.

  • When the data column Datatype is matching for the new value, then we can convert e.g. within a for each row and and assign Activitiy

  • When the data column Datatype is not matching for the new value, then we do the following:

  • Adding a new helper column

  • doing the conversion e.g. within a for each row

  • deleting origing column

  • renaming helper column to origin column name

  • moving helper column to the origin position by using the setOrdinal method of the data columns within an invoke method activity

For conversion / updating the column also have look here:
How to Update Data Column Values of a Data Table | Community Blog

e.g. DataColumn.Expression approach

I need to convert the column index 3 to number with one decimal digit

So the expected result would be 2.0; 3.0; 5.0 and so on

HI @roberto.piccolli

hope it will help for you

inside the loop you can use this condition = String.Format(“{0:F1}”, cint(CurrentRow(0)))

can see the output

image

1 Like

let me know its working or not for you

@roberto.piccolli

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