Replace commas with dots

Hello everybody i would like to replace commas with dots in CSV files. I converted the text file to CSV file. Only column B…please assist

Hi @pabaleloh

=> Use Read CSV to read the CSV file. Please remove Add Headers option in Properties panel.
Output → dt

=> Use For Each row in DataTable to iterate through each row

=> Use the below syntax in Assign activity

CurrentRow(1) = CurrentRow(1).Replace(",",".")

=> Write Ranfe Workbook dt back to excel.

Hope it helps!!

@pabaleloh
Read csv Activity to store that in datatable

Assign
  To: dataTable
  Value: dataTable.AsEnumerable().Select(Function(row) 
    Dim newRow = row
    newRow("ColumnB") = row.Field(Of String)("ColumnB").Replace(",", ".")
    Return newRow
  ).CopyToDataTable()

Write CSV

1 Like

Hie @pabaleloh
first read csv and store the data in the variable
use for each row activity and pass the output data
use assign activity and in assign create a variable and in the value pass your first column value eq - currentrow(“col1”).tostring
and again use side assign value and in that assign pass the (variable.replace(“,”,“.”))just like this .change variable name to your desired
i’m attaching a sample screenshot how you can work on that replace your activity with build table to read csv


mark this solution if it finds your desired requirement
cheers Happy Automation :grinning:

1 Like

Hi @pabaleloh

You can use the vb expression to replace the commas with dots in a specific column. Check the below steps,
→ Use the Read CSV activity to read the CSV file and store in a datatable variable called DT.
→ Then use the Invoke code activity and click on Edit code and paste the below expression,

DT.AsEnumerable().ToList().ForEach(Sub(row) row(1) = row(1).ToString().Replace(",", "."))

→ Then click on Edit arguments pass the DT as arument and select the In\Out option for the direction dropdown.
→ Then use the write csv activity to write the DT to the same csv file.

Check the workflow for better understanding,

Pass DT as argument to the Invoke code as below,

Hope it helps!!

1 Like

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