I am trying to read a *.csv
-file.
The *.csv
-file consist of two columns separated by semicolon (";").
I am able to read the *.csv
-file using StreamReader and able to separate each line by using the Split()
function. I want to store each column into a separate array and then display it.
Is it possible to do that?
You can do it like this:
Still wrong. You need to compensate for "" in quotes. Here is my solution Microsoft style csv.
LINQ way:
^^Wrong - Edit by Nick
It appears the original answerer was attempting to populate
csv
with a 2 dimensional array - an array containing arrays. Each item in the first array contains an array representing that line number with each item in the nested array containing the data for that specific column.You can use Microsoft.VisualBasic.FileIO.TextFieldParser dll in C# for better performance
get below code example from above article
I usually use this parser from codeproject, since there's a bunch of character escapes and similar that it handles for me.
Hi all, I created a static class for doing this. + column check + quota sign removal