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 7625639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:13:06+00:00 2026-05-31T05:13:06+00:00

I have a file reader object that i need to read a file with

  • 0

I have a file reader object that i need to read a file with tables in it. I want to create an object called Table to hold the row and column data from the read file. The trouble is, to read the whole page, i need to have a list of tables (there are more than one in the file). WHat is the best structure of my classes so that i am not exposing the data reader too much and passing it around too much?

My current line of thinking is this:

  1. Create a class that instantiates a list of tables and pass this class the reader.
  2. Run the reader and for each new table found, instantiate a new table object and pass along the reference to the reader so it can get row/column info.

Is this the best way to do this kind of task? Or is there a more efficient design to restrict the reader being passed too much? I have to use the using statement and it just doesnt feel right to use it in this nested design

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-05-31T05:13:07+00:00Added an answer on May 31, 2026 at 5:13 am

    You could potentially use the already available DataTable. There is a little bit of overhead in using them, but it sounds like it would be something easy to work with.

    You did say that the tables contain different structures. Is there anything in the file that identifies the table changing? This could make it more difficult if there are many ‘tables’ in the same file.

    You can simply use a collection of type DataTable if you want to have a list of them around. I suppose you could create your own class for this if your design warrants that.

    List<DataTable> tables = new List<DataTable>();
    

    and a sample method of how it may be used:

    private IList<DataTable> GetTables()
    {
        IList<DataTable> tables = new List<DataTable>();
        using (StreamReader reader = new StreamReader(pathAndFile))
        {
            //pseudo-code below
            //Iterate through tables in the file: foreach(DiscoveredTable table in file)
            //parse from csv: table = GetTableFromCsv(table.DataFromTheFile);
            //add to tables collection: tables.Add(table);
        }
    
        return tables;
    }
    

    Here is a link to a CSV parser if you are interested in going that route, since you said it is comma-separated.

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

Sidebar

Related Questions

I have a plain text file that I need to read in using C#,
Really newbie question: I have a .csv file that I need to read. I've
In the filesystem I have /file.aspx /directory/default.aspx I want to configure IIS so that
I have a very large XML file that I need to parse so I
I have a HttpServletResponse object and need to write a file contained in the
I have a CSV file listing items that I need to store within the
I have a pdf reader app which render the pdf file. It works fine
I have some content that i have to render as a excel file in
I have a Java process that opens a file using a FileReader. How can
I have a variable in code that can have file path or url as

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.