c# - File.ReadLine adds line breaks to CSV -
i have been converting exported document outlook csv used interpreted c# further manipulations. problem arises when using:
string path = @"contacts.csv"; program self = new program(); // open file read from. var readline = file.readlines(path); foreach (string line in readline) { console.writeline(line); console.readkey(true); }
to display following data:
which not expected output, , after hitting key pass readkey
rest of data displayed following: (blanked out contact numbers)
when csv it's self not contain line breaks (used replace function using ctrl+j mimic line break , replace nothing). csv looks like:
there no line breaks present, problem persists throughout document on iterations not others. why there new line breaks being added , being pushed iteration, why occouring? i've exhausted possibilities within skillset
i've tried forcefully removing new line breaks
string toprint = line.replace("\n"," "); console.writeline(toprint); console.writeline("\r\n"); console.readkey(true);
which returns same result & actively trying out other possible solutions , updating what's been tried
open csv file notepad++ , configure display white-space characters. you'll find something. maybe file has many spaces. displayed on console black. maybe line wrapped.
your code fine. no obvious mistakes. , neither readlines
nor writeline
broken.
Comments
Post a Comment