Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a .txt file consisting of very long paragraphs, with a single newline character separating each paragraph. I would like to convert this to a .csv format so that the file effectively has one column holding all the paragrahs, i.e. the first cell in each "row" contains the entire paragraph. However, I cannot use Excel to do this by simply opening the file in Excel and saving it as .csv, because some of my paragraphs are larger than the 10^15 character limit that MS Excel has on a single field.

Any suggestions how to do this?

share|improve this question

1 Answer 1

Assuming the text is properly escaped (i.e. embedded commas and linefeeds are double-quoted) you can just rename the file to .csv. There is nothing otherwise special about a CSV file format. It is essentially a text file.

There's actually a spec for CSV (you can read here). Note the rules for enclosing fields with double quotes: "Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes," and "If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote."

For example:

"You want to convert text to CSV," she noted.
This line doesn't need quotes (but they don't hurt).

Becomes:

"""You want to convert text to CSV,"" she noted."
"This line doesn't need quotes (but they don't hurt)."
share|improve this answer
    
It's not escaped. I guess I could do a find+replace for all the relevant characters to add the double quotes, though. Thanks. –  user216357 Apr 12 '13 at 1:08
2  
To turn the current text into valid CSV, you can replace every double quote with a pair of double quotes, and then add a double quote to the beginning and end of each line. –  Bradd Szonye Apr 12 '13 at 1:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.