How to read .csv file extension in .net C#
Asked
Active
Viewed 1,712 times
0
-
Do you wish to read the file contents, or simply the file extension??? – Adriaan Stander Dec 22 '10 at 05:57
-
2duplicates http://stackoverflow.com/questions/906841/csv-parser-reader-for-c & http://stackoverflow.com/questions/1375410/very-simple-c-csv-reader - please search before asking a question. And this question definitely doesn't deserve an upvote! – Kirk Broadhurst Dec 22 '10 at 06:03
-
possible duplicate of [Reading CSV files in .NET?](http://stackoverflow.com/questions/1405038/reading-csv-files-in-net) – Kirk Broadhurst Aug 12 '13 at 23:44
2 Answers
3
I just write my own - it's a one-liner!
using System.IO.File;
return ReadAllLines(@"C:\V3.txt").Select(line => line.Split(',')).ToList();
This will return a list where each item is a string[], contain each of the comma separated values.

Kirk Broadhurst
- 27,836
- 16
- 104
- 169
-
1That ones going to cause problems if the data contains embedded commas or double quotes. – Jonathan Wood Dec 22 '10 at 06:12
-
Very true. If I have to suffer with delimited files I always insist on non-comma delimited; tab or pipe delimited is much better. – Kirk Broadhurst Dec 22 '10 at 06:32
-
@ShrutiKapoor what do you mean? What's changed - which part doesn't work? – Kirk Broadhurst Aug 12 '13 at 23:44
0
FileHelper has mostly done the trick for me and it iss easy to use and has reasonable examples at the home page: http://www.filehelpers.com/

My Other Me
- 5,007
- 6
- 41
- 48