How to convert 1.475

How to convert value of a row

If a column has multiple rows

Column
0.05
0.23
1.475
1.433

Then the output should be
Column
0.05
0.23
1.48
1.43

This need to be handled in a notepad and not Excel

Have a look here:
grafik

1 Like

@dipon1112000

String.Join(Environment.NewLine, File.ReadLines("C:\Users\rlgandu\Downloads\N1.txt").Select(Function(line, index) If(index = 0, line, Double.Parse(line).ToString("F2"))))

Output:
image

1 Like

Hi @dipon1112000

modifiedContent=String.Join(Environment.NewLine, str1.Split(Environment.NewLine.ToCharArray()).Select(Function(line) If(Double.TryParse(line, Nothing), Math.Round(Convert.ToDouble(line), 2).ToString(), line)))

Hope it helps!!

1 Like

Hi thanks a lot but can I use the below format

String.Join(Environment.NewLine,column(“Percent”).Select(Function(line, index) If(index = 0, line, Double.Parse(line).ToString(“F2”))))

As the fraction is present in column (Percent)

@dipon1112000
we would recommend the following

  • Read CSV Activity (first line is header)
  • Convert within a for each row in DataTable
    • CDbl…toSring(“F2”) as shown above
  • Write CSV Activity

just ensure that the delimiter char is correctly defined

1 Like

@dipon1112000

Sequence:
Read Text File activity (output variable: notepadContent)
Assign activity:
transformedContent = String.Join(Environment.NewLine, notepadContent.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries).Select(Function(value) If(String.IsNullOrWhiteSpace(value), value, Double.Parse(value).ToString(“F2”))))
Write Text File activity (input: transformedContent)

@dipon1112000

Find the zip file

Forum.zip (470.5 KB)

Hope it helps!!

hi I have input as text1 but I have called it under read CSV with dt1 as datatable. So what should I write before Split (as the requirement is to convert the value of “Percent” (name of the Column) which is getting added to dt1 based on division method

A flow like:


will convert input:
grafik
to output:
grafik

Thank you very much, can you share the xaml

as it is just about 3 Activities, start to modell it by your own.
The XAML has a too high risk to be incompatible with your UiPath Studio Project.

we used
row("Column") = CDbl(row("Column").toString.Trim).ToString("F2")

Thank you :pray: very much :pray:

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