I am processing CSV File
Say
ABC|06|001
PPP|06|001
I am running LINQ to split the CSV
var path = Server.MapPath("~/App_Data/CSV.txt");
var _collectCSGData = from line in File.ReadAllLines(path)
let parts = line.Split('|')
select new { ID = parts[0],Assignment=parts[1]};
How to get the last item of each line ?
(i.e)
001
001
from line in File.ReadAllLines(path)
select line.Split('|').LastOrDefault()
Something like:
parts[parts.length -1]
should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With