For each excel row, I wish to retain only the first character of Column B and delete the rest of the text in the excel cell. For example Andy: to keep only ‘7’ in column B.
Hi @Snow , welcome to the community.
I am attaching a workflow for your reference which might help you to get your solution. Also, sending the sample excel file.
Grade.zip (7.3 KB)
Have a nice day!
Thanks & Regards,
Shubham Dutta
Hey @Snow,
Follow the below steps:-
- ForEachRow activity
2.Assign activity
Left = item(“Grade”)
Right = item(“Grade”).ToString.Split(";"c)(0).Trim.ToString
Thanks,
Sanjit
Hey!
Try this:
- Read range - Output as - DtOut
- Take one for each row in data table pass the DtOut
- Take one assign activity and create one integer variable as Counter initialize with 1
Assign Counter = 1
- Take one assign activity and pass the expression like this
Assign First = System.Text.RegularExpressions.Regex.Match(CurrentRow(1).ToString.Trim,"\d{1}").ToString
- Now use write cell activity to write back the values to excel
Range : "C"+(Counter+2).ToString
Value : First
- Assign Counter = Counter+1
Try this and let me know
Regards,
NaNi
Hi @Snow
Regex expression
OutData = System.Text.RegularExpressions.Regex.Match(CurrentRow("Grade").ToString,"^\d+(?=;)").ToString
Check out the XAML file
KeepOnlyFirstCharInExcel.xaml (11.7 KB)
Output
KeepOnlyFirstCharInExcel.xlsx (7.2 KB)
Regards
Gokul
Hi @Snow , welcome to the community!
In your for each row, you can assign item(1) = item(1).tostring.split(";"C)(0).tostring.trim
Then, you can see
Andy 7
Belle 6
Clark 9
Thanks for your help!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.