I want to create one csv file using C#.
I have some data which I want to write on multiple lines BUT within the same cell.
For example If I have following three sentences,
Sample sentence 1. This is second sample sentence. and this is third sentence.
I want to write all these three sentences within single cell of csv file but I want three of them on separate line.
My expected output is :
Sample sentence 1.
This is second sample sentence.
and this is third sentence.
Currently I am trying to achieve this by using \n
character between two sentences but when I do it this way, all three sentences go on separate row.
Can anyone please tell me how to solve this problem?
Always wrap your description in between "\" eg: CsvRow.Add("\"" + ID + " : " + description + "\"");
A CSV file is defined as one row PER LINE, with cells separated by comma (","). Now, your parser could support using "" to put together sentences in one cell, but that already stretches the specification. You could also encode the \n and decode this later, but then again this is not a vcsv file. At the end, you try to do something a csv file is per definition not defined to do. \n IS the new line symbol. NATURALLY an editor will show a new line here.
You might be able to change which tokens your application uses to parse rows from the csv file, but according to the definition of the csv file format, lines in the file are used to represent rows in the resulting tabular data.
CSV stands for "comma seperated values" which is just a description of a text-file. If you want to import into Excel and then only have the sentences in one line you should try:
instread of a simple
/n
To quote Wikipedia:
Like e.g.: