1
I have a C# project that is normally generating a file with extension. CSV, however I want to write a ;(point and comma) but it does is to separate the cell. There is some way to write without that happening?
Code:
arquivo.Detalhe = new List<Detalhe>();
int sequencial = 1;
foreach (var c in clientes)
{
Detalhe d = new Detalhe();
var cob = c.Value.First();
d.Endereco = c.Key.Endereco + "\";\"";
d.Bairro = c.Key.Bairro.Nome + "\";\"";
d.Cidade = c.Key.NomeCidade + "\";\"";
arquivo.DetalheGD7.Add(d);
}
Creating the archive:
var arquivo = Service.CriarArquivo(paraEnviar, inclusaoRadioButton.Checked, motivo);
TextFile.Serializer.Serialize(arquivo, localDoArquivoTextBox.Text + "\\ARQUIVO_.CSV");
The photo of how the file comes out:
Ignore the spacing, it’s the other information that hasn’t been filled in yet.
I believe that there will be no need to show the other files, since my doubt is just how to write the ; without the break of the cell happens.
What do you mean by "separate/break the cell"? Where you are opening the generated file to query, in Excel?
– Pedro Gaspar
@Pedrogaspar the
;
can be interpreted as cell splitter in spreadsheet readers like excel and Calc. Please add a row of your generated CSV file that contains a;
, generally what is done is to leave the entire cell within"
. It may be that this is just the setting of how your file is interpreted by these readers.– Costamilam
@Guilhermecostamilam I tried to put in all forms, but still could not put. I tried to configure excel to not understand ; as a cell splitter but without success.
– Bruno Miqueas
@Brunomiqueas put the text of your CSV, for example,
RUA GOV SAMPAIO; CENTRO - FORTALEZA, FORTALEZA
– Costamilam
@Guilhermecostamilam Do you speak of putting via code? I tried via code but it did not help. And if I edit by CSV, it is good. But is there no other solution? And that’s what you meant by "putting the text of your CSV"?
– Bruno Miqueas
Have you ever opened a CSV file with a text editor? Like the notepad, Notepad++, ...? If not, do this and you will understand
– Costamilam
O ; appears there this way: GOV SAMPAIO STREET; CENTER - FORTRESS; FORTRESS;. What should I do?
– Bruno Miqueas
just write to the first line of your Sep file=_
– Lucas Miranda
"_" being your new separator, it can be anything, literally, e.g.=+
– Lucas Miranda
Thank you all, you solved my problem.
– Bruno Miqueas