How can I escape commas in a CSV file?

I thought there were two ways to do this: either enclose the field containing the comma in quotes, or place a backslash before the comma. However neither of these is working; when I load up the CSV file into OpenOffice Calc, LibreOffice Calc, or Microsoft Excel, the comma is treated like a field delimiter and my field is split in two, breaking the layout. What am I doing wrong?

4

1 Answer

Try authoring the data in Calc or Excel and then save/export it as CSV. What does it produce when you view the CSV in a plaintext editor?

In my testing with Excel, I see it encloses the field with the comma in double quotes and correctly interprets it when I re-epen it.

When you edit the data in a plaintext editor, make sure you're using regular double quotes (") and not so-called smart quotes (“”).

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like