line split in C# without any reason -


i m reading text file file.readallline use foreach function read use line worked fine @ 1 point break 1 line unnecessarily 2 lines

string[] lines = file.readalllines("yilc2.csv"); foreach (string line in lines)         {             console.writeline(line);         }  

line in csv file breaks two

12345.67890,foobar,barbaz,spamham,female,17,town,12345678901,example@example.com,"block 42 flat no 05 fourth floor  jubilee garden apartment dha phase 2",university,,,barbaz,,,,mba,,no, 

individual values in csv files allowed have embedded line breaks, long these values surrounded double-quotes (reference).

a field contains embedded line-breaks must surounded double-quotes

here example: point of view of csv reader file has single line 3 values:

"one","two three","four" 

in c# notation values "one", "two\r\nthree", , "four"

readalllines method pays no attention double-quotes, point of view file contains 2 lines - "\"one\",\"two" , "three\",\"four\"".


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -