Forum Discussion
Save as CSV file (UTF-8) with double quotes - how?
cantikaliem_ Thanks, but that doesn't work if there is a mix of text and numbers.
I figure out this customer formula which will work for all scenarios.
\"#\";\"#\";\"#\";\"@\"
This works because you can have multiple custom formula's separated by ; for different data types.
<Format for POSITIVE Numer>;<Format for NEGATIVE Numer>;<Format for ZERO>;<Format for TEXT>
YellowCylinder It shouldn't be this hard though, do you agree?
- YellowCylinderAug 02, 2021Copper ContributorActually, I just did some testing and ended up not using my new custom format. As far as I can see Excel adds quotes if needed when a cell contains a comma whether you save it as UTF-8 or normal CSV, this is the latest Excel 2016. For my use case that is fine, although I can understand why someone people would want it fully on or fully off.
- LordNeno585Sep 09, 2021Copper ContributorAll these replies and torture that people have just shows how retarded microsoft developers are. You cant paste data properly between two microsoft products. Their developers should be used only for transcribing from pdf to word and nothing else. Trashbags
- ZenAtWorkOct 26, 2021Copper Contributor
Okay, so as a software dev I've been cursing about this particular idiocy for years. There are a few fixes I've found
First off MS has gone with a "quotes only if something in the cell conflicts with the CSV format" approach. So
John, Doe, "said """hello""" to me, but only once" Jane, Doe, did not.
This is even more obnoxious, insofar as it's both inconsistent, and still ignores some of the worst offenders: legitimate commas IN THE DATA. As a dev I'm often having to import/ingest large volumes of data, often times containing legitimate text passages. Excel makes this a bloody nightmare (especially on a mac).
Some things that have worked for me: if the text is to be simply output later on on-screen, a substitution pattern works great, If the text is going to wind up on a website, while in Excel, but BEFORE you export, replace all instances of `"` (double quote) with """ all `'` (apostrophes) with "'", and all `,` (commas) with ",". The advantage here being that when the characters render again on screen, they will LOOK exactly as they originally did to the user. They won't know they've been swapped out for the HTML char codes, and browsers auto-correct this when you copy+paste out.
Not working on a webpage? Did you know that there's a difference between “ and " (colors are added by me to make it easier to see)?
Let me explain: A decade or two back, MS decided what the world really NEEDED was "smart punctuation". Basically, "we need quotation marks that are slightly angled and INVERTED so the start and end ones are DIFFERENT!" Don't ask me. The relevant bit is, though,
"is not the same as“”, nor is ' and ‘, or even , and ‚. The green ones are the native, normal punctuation we've all grown up with. The red ones are "smart".
...BUT! They ARE different characters to the COMPUTER. Nothing that parses CSV will split on "‚". Or treat a string delimited “like this” as though it's a standalone unit "like this". This is relevant because again: if you do your replaces in excel before exporting, to a HUMAN on pretty much ANY MEDIA we cannot tell a difference. But you'll know that EVERY comma in your CSV is a true delimiter. As a developer I've lost hours of my life to trying to figure out why this code someone copied out of Slack won't run, until I eventually remembered to check that "their string" actually WAS one.
The others are programmatic fixes; I'm trying to post layperson-compatible, EASY solutions. If anyone wants the macro code, just drop a reply and I'll post again.
Hope this helps someone!
- RogerDeJongeAug 02, 2021Copper ContributorOn mac I use CSV editor (small fee) solves all the CSV manipulation. On Windows is a freeware tool called: Ron’s Editor.
To me it’s unbelievable that Excel can’t handle this in a user friendly way. I live in The Netherlands and CSV’s are exported with a semi colon (;) so we need to replace that too.