I’m using read csv file to save it in a datatable variable and use the fields “Quantidade” and “Valor_total” as a filter to return “Item” value. but when this csv file is generated by my company’s system the values come with spaces, so if i want to use the values to filter i’ll have to put the spaces, like the example below:
Is there a way to handle with this? I know that if i open this csv in excel and save, this spaces desapear, but i have to do this manually. Is there an activity to make it?
I’ve made a quicky search about these 3 topics and looks like trim() and LINQ are the best options, but i don’t know how to apply it in my case, can you help me?
Read the csv and get the data to a Datatable( space will be there)
2)(From r In dtData.AsEnumerable
let ra = r.ItemArray.Select(Function (x) x.ToString.Trim.Replace(" ",“NA”)).toArray()
Select dtCorrected.Rows.Add(ra)).CopyToDataTable()
From the datatable it will fetch each row as an array of data and we are using the Trim and replace to remove the anonymous spaces. After that, it is getting copied to a new Datatab;le.