Output double with comma in activity "write csv"

Can I output columns with type double with comma instead of dot in a csv file using standard activity “Write csv”?

Hi @HGraich

Welcome to the community!! :smiley:

So to understand your problem, you have bunch of values something like (1234,00) and you want to convert it to double when writing the data to a CSV right? so the comma is there instead of the dot.

Well, if the comma is there, as far as I know, it is considered as a String. So you will not be able to directly convert it to a double unless you replace the comma to the dot. In case you want to convert to double, do the following steps before writing to CSV.

Add a For Each Row activity to loop through the data table
within the loop add an assign activity and do the replacing like this
row(“ColumnName”) = row(“ColumnName”).ToString.Replace(",",".")

This will replace all the commas in that column to the dot. Now you can convert the values to double :slight_smile:

If you are to convert through Uipath itself, you can try the below code to convert it
Double.Parse(row("ColumnName").ToString)

let know whether this helps.

6 Likes

Hi @Lahiru.Fernando,

thanks for your answer. But the problem is a bit different: I read an excel with Read range containing a column with double values (in excel these values are displayed with commas, as I work in Germany). When writing this datatable back to the csv file, these values are output with dots, which is not what I want in this place. Any idea?

Hi @HGraich

Well, its like this. So the excel has double values. But it is shown in the format that has the comma in excel itself. However, the format which excel shows you does not actually apply when extracting data from excel to UiPath. Irrespective of the format excel shows, UiPath extracts the exact value which is in excel. So in your case, its the double value in normal format with the dot :slight_smile:

So, in that case, within Uipath studio, you need to write a workflow to convert it to the format that you need which uses the comma. Then writing the result to excel will give you the exact output. So I have done a sample workflow for you. In my case, the reading excel has the normal number format, but writes back the same result with the comma. So basically it replaces the dot with the comma…

Check out the attached…

Result.xlsx (7.1 KB)
TestData.xlsx (7.8 KB)
CommaNumberFormat.xaml (6.3 KB)

Let know whether this works for you…

if it works, please make sure to mark my answer as the solution too…:slight_smile:

1 Like

Hi @Lahiru.Fernando,
thank you for the solution, this obviously works. But I wonder if there should not be a more natural solution, e.g. a possibility, that the Write CSV activity exports data in the correct regional format defined for example by settings of os/computer/environment or explicitly defined in Project settings or (new) properties of the export activity (along the lines of Locale in Java).

Regards,
Harald

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