• Ivy Seo

Read Csv File line by line

Entire code in C# :

public void readAssetsCsvFile()
        {
            int counter = 0;
            string line;
            // Read the file and display it line by line.  
            System.IO.StreamReader file =
                new System.IO.StreamReader(@"/home/ivy/Desktop/postgres_data_test/cvs_files/Assets.csv");
            while ((line = file.ReadLine()) != null)
            {
                System.Console.WriteLine(line);
                insertAssets(line);    // pass the row to ()
                counter++;
            }
            file.Close();
            System.Console.WriteLine("There were {0} lines.", counter);
        }