I am looking for some best practices as far as handling csv and tab delimited files.
For CSV files I am already doing some formatting if a value contains a comma or double quote but what if the value contains a new line character? Should I leave the new line intact and encase the value in double quotes + escape any double quotes within the value?
Same question for tab delimited files. I assume the answer would be very similar if not the same.
Usually you keep
\nunaltered while exploiting the fact that the newline char will be enclosed in a" "string. This doesn’t create ambiguities but it’s really ugly if you have to take a look to the file using a normal texteditor.But it is how you should do since you don’t escape anything inside a string in a CSV except for the double quote itself.