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

  • Home
  • SEARCH
  • 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 7510989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:24:16+00:00 2026-05-29T23:24:16+00:00

As part of a recent project I had to read and write from a

  • 0

As part of a recent project I had to read and write from a CSV file and put in a grid view in c#. In the end decided to use a ready built parser to do the work for me.

Because I like to do that kind of stuff, I wondered how to go about writing my own.

So far all I’ve managed to do is this:

//Read the header
            StreamReader reader = new StreamReader(dialog.FileName);
            string row = reader.ReadLine();
            string[] cells = row.Split(',');

            //Create the columns of the dataGridView
            for (int i = 0; i < cells.Count() - 1; i++)
            {
                DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn();
                column.Name = cells[i];
                column.HeaderText = cells[i];
                dataGridView1.Columns.Add(column);
            }

            //Display the contents of the file
            while (reader.Peek() != -1)
            {
                row = reader.ReadLine();
                cells = row.Split(',');
                dataGridView1.Rows.Add(cells);
            }

My question: is carrying on like this a wise idea, and if it is (or isn’t) how would I test it properly?

  • 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-29T23:24:17+00:00Added an answer on May 29, 2026 at 11:24 pm

    As a programming exercise (for learning and gaining experience) it is probably a very reasonable thing to do. For production code, it may be better to use an existing library mainly because the work is already done. There are quite a few things to address with a CSV parser. For example (randomly off the top of my head):

    • Quoted values (strings)
    • Embedded quotes in quoted strings
    • Empty values (NULL … or maybe even NULL vs. empty).
    • Lines without the correct number of entries
    • Headers vs. no headers.
    • Recognizing different data types (e.g., different date formats).

    If you have a very specific input format in a very controlled environment, though, you may not need to deal with all of those.

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

Sidebar

Related Questions

As part of a recent project, I have created a Cell Table that holds
Hey guys in my recent project i have used the valums file uploader for
As part of a recent programming project I compiled a database, the contents of
Here is part of a stack-trace from a recent run of an unreliable application
In a recent project, part of the assignment is replacing a Visual Foxpro application
Part of my web application is a background script that polls from a beanstalkd
Part of an app I am working on includes a log file viewer, with
I want to count the lines of code in a multi-file Python project as
In couple of recent projects that I took part in I was almost addicted
print Español\nPortuguês\nItaliano.encode('utf-8') Errors: Traceback (most recent call last): File , line 1, in print

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.