I have a problem reading a txt file that has its columns separated by a comma but also has monetary values that are being cut and should not, because they are in quotation marks. Here is an example line:
Nome, Idade, Valor a receber, Valor pendente, descricao
Teste, 25, "1.234,30", "987,90", teste
After you have read the file
string[] todasLinhas = File.ReadAllLines(arquivo, Encoding.GetEncoding("iso-8859-1"));
I try to cut by comma
foreach (string linha in todasLinhas)
{
string[] colunas = linha.Split(',');
}
The result looks like this:
Teste
25
"1234
30"
"987
90"
teste
Is there any way to make Split not cut when the character is enclosed in quotation marks? or is there any other solution you can share?