Question posted 2010 · +8 upvotes
I used Python to generate a CSV file. But when I open it in Excel, Excel will auto recognize a string into a number if it could be converted.
e.g.33E105 becomes 33*10^105, which is actually an ID, not a number.
How to disable this in Excel while opening a CSV file? Or I need to resort to a excel-python library to output a excel file and specify the format myself?
I also found a similar question without good answers on the web.
Thanks!
Accepted answer +4 upvotes
You could precede it with a single quote, forcing it to text.
A fun answer is you could keep the first eight rows blank (it only processes the first eight rows to determine data type), although I think this may blank all your data entirely. You could hide those empty rows.
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
.