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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:24:27+00:00 2026-06-13T08:24:27+00:00

Possible Duplicate: Very simple C# CSV reader In my application the user can export

  • 0

Possible Duplicate:
Very simple C# CSV reader

In my application the user can export and csv files from and to a datagridview, this works okay but there is some minor problem.

As you know csv files use the comma sign to sepperate items.

Sometimes one of the cells has a comma sign for example (2,5 hours).

When importing the csv it thinks that the comma sign between 2,5 is a seperator, because of this it will put 2 in a cell and 5 in the next one.

How can i fix this problem.

This is my csv for importing csv’s

dataGridView1.Rows.Clear();
        try
            {
                if (openFileCsv.ShowDialog() == DialogResult.OK)
                {
                    string csvPath = openFileCsv.FileName;

                    if (System.IO.File.Exists(csvPath))
                    {
                        System.IO.StreamReader fileReader = new System.IO.StreamReader(csvPath, false);


                        //Reading Data
                        while (fileReader.Peek() != -1)
                        {
                            fileRow = fileReader.ReadLine();
                            fileDataField = fileRow.Split(',');
                            dataGridView1.Rows.Add(fileDataField);
                        }
                        fileReader.Dispose();
                        fileReader.Close();
                    }
                    else
                    {
                        MessageBox.Show("CSV Bestand niet gevonden.");
                    }
                }

                DataLoaded = true;

            }

This is my code for exporting the csv.

if (saveFileCsv.ShowDialog() == DialogResult.OK)
            {
                string CsvFpath = saveFileCsv.FileName;

                try
                {
                System.IO.StreamWriter csvFileWriter = new System.IO.StreamWriter(CsvFpath, false);

            int countColumn = dataGridView1.ColumnCount - 1;

            int iColCount = dataGridView1.Columns.Count;

            foreach (DataGridViewRow dataRowObject in dataGridView1.Rows)
            {
                //Checking for New Row in DataGridView
                if (!dataRowObject.IsNewRow)
                {
                    string dataFromGrid = "";

                    dataFromGrid = dataRowObject.Cells[0].Value.ToString();

                    for (int i = 1; i <= countColumn; i++)
                    {
                        dataFromGrid = dataFromGrid + ',' + dataRowObject.Cells[i].Value.ToString();
                    }

                    //Writing Data Rows in File
                    csvFileWriter.WriteLine(dataFromGrid);
                }
            }


            csvFileWriter.Flush();
            csvFileWriter.Close();
        }
        catch (Exception exceptionObject)
        {
            MessageBox.Show(exceptionObject.ToString());
        }
  • 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-13T08:24:27+00:00Added an answer on June 13, 2026 at 8:24 am

    You can either use another character, other than a comma to separate the variables, or you could enclose the values in quotes.

    Have a look at this.

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: very simple delegate musing I've been wondering what's the difference between this
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Console.Readline() max length? In my attempt to find a very simple text
Possible Duplicate: Why can't decimal numbers be represented exactly in binary? i get very
Possible Duplicate: C programming division probably my question is very simple and stupid. I
Possible Duplicate: Would a multithreaded Java application exploit a multi-core machine very well? I
Possible Duplicate: Why use getters and setters? Yes, It's a very simple thing but
Possible Duplicate: VBA collection: list of keys Maybe it is a very simple question,
Possible Duplicate: Multiline strings in Javascript In Ruby you can do something like this:

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.