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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:44:33+00:00 2026-05-30T23:44:33+00:00

Hi I have a program to parse a CSV and fill it into a

  • 0

Hi I have a program to parse a CSV and fill it into a DataGridView.

When I’m doing it like this it works great:

        openFileDialog1.Filter = "CSV Files(*.csv)|*.csv";
        openFileDialog1.FilterIndex = 1;
        openFileDialog1.RestoreDirectory = true;

        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            txtCsvSource.Text = openFileDialog1.FileName;
            Encoding iso = Encoding.GetEncoding("ISO-8859-1");
            using (CachedCsvReader csv = new CachedCsvReader(new StreamReader(txtCsvSource.Text, iso), true))
            {
               csv.MissingFieldAction = MissingFieldAction.ReplaceByEmpty;
               dataGridView1.DataSource = csv;
            }
        }

But when Im doing it like this:

        openFileDialog1.Filter = "CSV Files(*.csv)|*.csv";
        openFileDialog1.FilterIndex = 1;
        openFileDialog1.RestoreDirectory = true;

        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            txtCsvSource.Text = openFileDialog1.FileName;
            dataGridView1.DataSource = QrFunctions.parsecsv(txtCsvSource.Text);
            dataGridView1.Update();
        }

with the QrFunctions.parsecsv being like:

public CachedCsvReader parsecsv(string csvpath)
    {
        Encoding iso = Encoding.GetEncoding("ISO-8859-1");
        using (CachedCsvReader csv = new CachedCsvReader(new StreamReader(csvpath, iso), true))
        {
            csv.MissingFieldAction = MissingFieldAction.ReplaceByEmpty;
            return csv;
        }
    }

the DataGridView is empty… why? I simply have no idea 🙁 I just wanted to use this function to parse in another Class, so I created the class QrFunctions.

  • 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-30T23:44:35+00:00Added an answer on May 30, 2026 at 11:44 pm

    Try this.

    public CachedCsvReader parsecsv(string csvpath)
        {   
            Encoding iso = Encoding.GetEncoding("ISO-8859-1");
            CachedCsvReader csv = new CachedCsvReader(new StreamReader(csvpath, iso), true)
            {
                csv.MissingFieldAction = MissingFieldAction.ReplaceByEmpty;
                return csv;
            }
        }
    

    Please remember to dispose of the object yourself, since I have removed the using statement or implement the IDisposable pattern

    Thanks to @MartiniMoe for constructive comments.

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

Sidebar

Related Questions

I have a program that receives something like this from a settings file: C:\Files\App
I have written a simple C++ shell program to parse large XML files and
I have written a program in C to parse large XML files and then
In a contact manager program I've been storing data in CSV files for each
I have a Perl program that I've written that parses SQL-like statements and creates
I have this program that takes one argument for the source file and then
I have program that needs to parse XML that contains character entities. The program
I have c# program that among other things should be able to parse a
I'm writing a program to parse some third-party XML files. The structure is something
We would like to have user defined formulas in our c++ program. e.g. The

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.