0

Hi,

Im a newbie to the world of C#. Im having trouble trying to get this little app to read a csv into an array.
I know that this should be a very simple thing to acheive, but since im new to c# im having a little trouble getting it to work.
the CSV file is a very basic one. its structured like this.

123456,0123345,0123213,0134343,54353452,34234234,13231313
313122,3231233,1231231,1312323,53454555,56656466,56465654

there are no special characters or quotes in the csv files that i will be importing.

if one of you fine c# gurus could point me in the right direction.

using System;
using System.IO;

class CSVReader
{
    public static void Main()
    {
        try
        {
            string FileName = "text file name here";
            using (StreamReader sr = new StreamReader(FileName))
            {
               
                string line;
                // Read and display lines from the file until the end of 
                // the file is reached.
               
                while ((line = sr.ReadLine()) != null)
                {
                    
                    Console.WriteLine(line);
                    
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("The file could not be read:");
            Console.WriteLine(e.Message);
        }
    }

any help greatly appreciated

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by iamthwee
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.