I have a code that reads a CSV and saves the information in the database, however I ended up getting a "different" CSV from what I am used to reading. This CSV comes with double quotation marks in the information.
Ex: "0", "20151109", "171729", "20151101", "20151106", "V3.0", "00", "20151109171729", "000001"
Is there a possibility of doing replace
? The remove
function I tried it just removes the first quotation marks. (if there is a possibility to do the remove also, I would like an example as it did not work correctly here). I'll show you a piece of what's done.
if (Directory.Exists(pasta_tempFisico))
{
using (sr)
{
while (!sr.EndOfStream)
{
sline = sr.ReadLine();
if (sline.Substring(1, 1) == "0")
{
string[] DadosRPS = sline.Split(';');
dtCriacaoArqHd = DateTime.Parse(DadosRPS[1].Substring(1, 4) + "/" + DadosRPS[1].Substring(5, 2) + "/" + DadosRPS[1].Substring(7, 2) + " " + DadosRPS[2].Substring(1, 2) + ":" + DadosRPS[2].Substring(3, 2) + ":" + DadosRPS[2].Substring(5, 2));
dtInicialHd = DateTime.Parse(DadosRPS[3].Substring(1, 4) + "/" + DadosRPS[3].Substring(5, 2) + "/" + DadosRPS[3].Substring(7, 2));
dtFinalHd = DateTime.Parse(DadosRPS[4].Substring(1, 4) + "/" + DadosRPS[4].Substring(5, 2) + "/" + DadosRPS[4].Substring(7, 2));
VersaoHd = Convert.ToString(DadosRPS[5]);
codIdnRedeHd = Convert.ToInt32(DadosRPS[6]);
numSeqArqHd = Convert.ToInt32(DadosRPS[7]);
numSeqRegArqHd = Convert.ToInt32(DadosRPS[8]);
}
Note: sline.Substring(1, 1)
is in this way only by test, since in the removal it would be (0,1) because of the quotation marks.