is it possible to read csv file based on line. Like give a line number and it retrieves that particular line in CSV.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you just want to read a line of a text file(like csv), the easiest approach is using
File.ReadLinesandEnumerable.ElementAtOrDefault:Use it in this way:
That returns the 100th line (or
nullif there are less than 100 lines).Here’s another similar method that returns a range of lines:
return the first 10 lines:
Note that
File.ReadLinesis similar to aStreamReader, it does not read the whole file at once into memory(asFileReadAllLines), just as much as necessary.