4 ms·
I posted this the last time there was a discussion about CSV and excel: If you are generating the CSV yourself, save yourself some agony and just wrap the text
by niggler 13y ago
I posted this the last time there was a discussion about CSV and excel:
If you are generating the CSV yourself, save yourself some agony and just wrap the text in =""
$ cat test.csv
="12.34567890124312341234123412341234",="1-5"
$ open -a Microsoft\ Excel test.csv
https://news.ycombinator.com/item?id=5514587 https://news.ycombinator.com/item?id=5514587
Explanation:
It uses another auto trick: if the leading character is '=', the result is treated as a formula.
Thus, you can actually write formulas in your CSV and excel will interpret appropriately:
$ cat test.csv
=1+1,="1-5"
$ open -a Microsoft\ Excel test.csv
You should see the value '2' (with content `=1+1`)
https://news.ycombinator.com/item?id=5514704 https://news.ycombinator.com/item?id=5514704
- spikels 13y agoAn alternative solution that works is some situations is to format the column as "Text". However you must do this before pasting the data into the cells or else it will already be converted. I use this technique for zip codes which can have leading zeros.