java - CSVReader cannot read a line correctly -
i have .csv file 12 columns , read file csvreader class.
list<string[]> rows = reader.readall(); but found string[] have less 12 elements. when debugged, found csv text format problem.
there 2 problems:
some columns end backslash.
for example,
"column content\", "column b content"read 1 column\"seen escape character.some cells' contents have
\"in them.for example, in 1 row, column a's content command line:
"d -r u+rwx \""${mytmp}\"" > /dev/null 2>&1; rm -fr \""${mytmp}\"" >"
so cannot think of replacement strategy deal format problem. (e.g replace \ \\, works "contenta\","contentb" situation, don't work \" when cell's content )
any suggestions? welcome discuss bad formatting problems , solutions experienced in csv files reader has problem reading correctly.
i think if replace \", \\", solve problem. unix command lines not contain , character right after \". yo may have extend \", " \\", " or maybe adding whitespaces.
a special case when last column ends, \"<nl> should replaced \\"<nl> <nl> whatever line delimiter have (\r\n, \r or \n)
Comments
Post a Comment