Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:04:57+00:00 2026-06-11T10:04:57+00:00

is it possible to read csv file based on line. Like give a line

  • 0

is it possible to read csv file based on line. Like give a line number and it retrieves that particular line in CSV.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:04:58+00:00Added an answer on June 11, 2026 at 10:04 am

    If you just want to read a line of a text file(like csv), the easiest approach is using File.ReadLines and Enumerable.ElementAtOrDefault:

    public static String getFileLine(String path, int indexOfLine)
    {
        return File.ReadLines(path).ElementAtOrDefault(indexOfLine);
    }
    

    Use it in this way:

    String line = getFileLine(@"C:\Temp\CsvFile.csv", 99);
    

    That returns the 100th line (or null if there are less than 100 lines).

    Here’s another similar method that returns a range of lines:

    public static IEnumerable<String> getFileLines(String path, IEnumerable<int> lineIndices)
    {
        return File.ReadLines(path).Where((l, i) => lineIndices.Contains(i));
    }
    

    return the first 10 lines:

    IEnumerable<int> range = Enumerable.Range(0,10);
    IEnumerable<String> lines = getFileLines(@"C:\Temp\CsvFile.csv", range);
    foreach (String line in lines)
        Console.WriteLine(line);
    

    Note that File.ReadLines is similar to a StreamReader, it does not read the whole file at once into memory(as FileReadAllLines), just as much as necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to read CSV file using Entiry Framework 4 such that it
Is it possible to read a specific line using SuperCsv? Suppose a .csv file
Using Python's csv module, is it possible to read an entire, large, csv file
Is possible to read from a txt file in loop like this? files names:
Is it possible to read the content of a file that has been selected
Possible Duplicate: Read a file from line X to line Y? I know this
is it possible to programmatically have access open a certain csv file and read
I'm trying to read a csv file that holds several values in every cell
Possible Duplicate: Get and Parse CSV file in android I would like to store
I need to read a CSV file which has fields that have a comma,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.