0

How to read .csv file extension in .net C#

3

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

That ones going to cause problems if the data contains embedded commas or double quotes.
Very true. If I have to suffer with delimited files I always insist on non-comma delimited; tab or pipe delimited is much better.
@ShrutiKapoor what do you mean? What's changed - which part doesn't work?
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/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.