Reputation: 237
I have a simple 3 column csv file and i need to exctract only the information from the first column. I was thinking of regular expressions, but i am hoping there is an easier more efficient approach.
Any help will be much appreciated.
Thanks
Upvotes: 2
Views: 19246
Reputation: 23403
If you want to extract that data into a class object, CsvHelper (a library I maintain) is a good option.
var csv = new CsvHelper( File.OpenRead( "file.csv" ) );
var myCustomObjects = csv.Reader.GetRecords<MyCustomObject>();
Upvotes: 0
Reputation: 45119
As stated in dozens of questions before there are two candidates for easy reading of .csv files:
Upvotes: 0
Reputation: 5182
I'd go like this : load the csv file to a datatable and then handle it however i want, by column, or by row. here's a link with some directions
Upvotes: 0
Reputation: 499352
You can use the TextFieldParser
class that is in the Microsoft.VisualBasic.FileIO
namespace.
It will parse the file and the resulting object can be queried, so you will be able to get the values in the first column.
Upvotes: 1