c# - How do I remove the quotation marks from a .csv file? -


i read in .csv file.

the contents of looks this:

1;"final60";"united kingdom";"2013-12-06 15:48:16";

2;"donnyr8";"netherlands";"2013-12-06 15:54:32"; etc

at moment trying remove quotation marks each line using replace method. have attempted doesn't appear anything. although doesn't seem break program in anyway.

try {     string item2;     list<string> list = file.readlines("file.csv").tolist();     foreach (string listline in list)     {          console.write("#  ");          // seperate line new list ;           list<string> listitems = listline.split(';').tolist();          foreach(string item in listitems)          {               if (item == "&quot;")               {                     item2 = item.replace("&quot;", "");               }               else               {                     item2 = item;               }               console.write(item2);          }          console.writeline("\n");     } } catch (exception e) {     // let user know went wrong.     console.writeline("the file not read:");     console.writeline(e.message); } 

how can remove quotation marks in each line?

one approach regex, consider pattern:

\" 

regular expression visualization

debuggex demo

it match " in string this:

var s = regex.replace(input, pattern, string.empty); 

here input entire file or 1 line, pattern \", , s resulting string after removal of double quotes.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -