How to read columns of a longer .CSV file

May 11, 2013 at 12:03 PM
Edited May 11, 2013 at 1:21 PM
Good day, I have a .CSV file with 3550 rows of data (stored in 5 columns).

I tried using your great add-on in VB.NET, but CsvReader only reads last 300 rows while all the others are not shown in my console application.

What could be the solution?

Thanks a lot in advance.

Dejan
Coordinator
May 11, 2013 at 12:14 PM
Hi Dejan,

I suspect this is just down to how you're using it. Please post your code so I can assist you in correcting it.

Best,
Kent
May 11, 2013 at 1:20 PM
Edited May 11, 2013 at 1:22 PM

I am total beginner with parsing/reading data so all I produced is this code. As mentioned, the output is only 300 rows in console window despite much larger amount of data (I want to parse 3550 rows and show them in console). My code is pasted below:

Using reader = New CsvReader("C:\program\earthquake_acceleration_data.csv")
        reader.ValueSeparator = ";"

        While reader.HasMoreRecords

            Dim row As DataRecord = reader.ReadDataRecord()
            Console.WriteLine(row.Item(1))
        End While

End Using
Coordinator
May 11, 2013 at 1:36 PM
Hi Dejan,

Thanks for the code. It looks fine.

Are you sure you've not just got your console set to buffer only 300 lines? Go to the properties on your console and check the Layout section:

Image

Notice the default buffer height is 300. I suspect this is all that's happening: you can only see the last 300 lines of your data because the console is discarding the lines prior to this.

You could also output the read.RecordNumber property after your While loop to see how many records have actually been parsed:
Console.WriteLine(reader.RecordNumber)
HTH,
Kent
May 11, 2013 at 2:26 PM
Ohhh, I had max. buffer settings at 300 and this caused trouble. Now I fixed that and I'll be able to do some linear fitting of my earthquake acceleration equations.

Thanks a lot, this will help my research paper.

Dejan
Slovenia