I'm able to read rows separated by "~" but once I try to read the values separated by comma, my output returns nothing.
Any help is appreciated!

strInput is a .csv file.

 Content= strField[0],strField[1],strField[2],strField[3],srField[4],strField[5]~
          strField[0],strField[1],strField[2],strField[3],srField[4],strField[5]~
          strField[0],strField[1],strField[2],strField[3],srField[4],strField[5]~





using (StreamWriter write = new StreamWriter(filePath, true)){

string[] line = strInput.Split('~');
foreach (string part in line)
 {
   string[] strField = part.Split(',');
   strDetails += "" + "," + "Heading1" + "," + "Heading2 + "," + strField[0] + "," + strField[5] + "," + strField[1] + "," + strField[2] + "," + strField[4] + "~";
   write.WriteLine(strDetails);
    }
}

your quotation marks are incorrect. You have:
strDetails += "" + "," + "Heading1" + "," + "Heading2 + "," + strField[0] + "," + strField[5] + "," + strField[1] + "," + strField[2] + "," + strField[4] + "~";
when it should be:
strDetails += "" + "," + "Heading1" + "," + "Heading2" + "," + strField[0] + "," + strField[5] + "," + strField[1] + "," + strField[2] + "," + strField[4] + "~";

This is why using String.Format is so much nicer, you don't fail to see the missing quotation marks:
strDetails += string.Format(",Heading1,Heading2,{0},{1},{2},{3},{4}~", strField[0], strField[5], strField[1], strField[2], strField[4]);

Hope this helps,
Mark A. Malo

Edited 2 Years Ago by MarkAMalo: lol, missed quotation mark

This question has already been answered. Start a new discussion instead.