How to remove [ ] from column in excel

Hi all,
How to remove the from column city in excel file. Please check the below file.
test.xlsx (11.1 KB)
Please guide me on this.

@lakshmi.mp,

Do you need to remove it after reading the file as datatable or in the file itself you need to remove it.

Hi @lakshmi.mp

Try this in Invoke Code

dt.AsEnumerable().ToList().ForEach(Sub(r)
            r("Column") = r("Column").ToString().Replace("[","").Replace("]","")
End Sub)

Regards,

1 Like

@lakshmi.mp

Output:

Regards,

2 Likes

Hi @lakshmi.mp

Use For Each row in datatable
assign: row("City") = System.Text.RegularExpressions.Regex.Replace(row("City").ToString(), "\[|\]", "").Trim()

Hi @lakshmi.mp

You can use a simple
Read Range Workbook: read the sheet.
Use a loop For each ROw in datatable
use an assign activity:

CurrentRow("City")=CurrentRow("City").toString.Trim("[]".ToCharArray)

Write Range in same sheet or other one.
Here’s a sample xaml.
test.xlsx (10.2 KB)
Test.xaml (8.4 KB)

Happy Automation! :smiley:

Hi @lakshmi.mp

CurrentRow("City")=CurrentRow("City").ToString().Replace("[", "").Replace("]", "")

Hi @lakshmi.mp

Try below steps

  1. Use Read Range Activity
  2. Use For Each Row in Data Table Activity
  • Take Assign Activity

CurrentRow("City") = CurrentRow("City").ToString.Trim("[]".ToCharArray)

Hope it’ll helps you :slight_smile:
Cheers!!

@Sai_chnadrika_Kopparapu , thanks a lot for helping. It’s working fine

1 Like

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