Openpyxl cell format

Gregory Ewing greg.ewing at canterbury.ac.nz
Mon Jun 5 19:48:54 EDT 2017


Mahmood Naderan wrote:
> Maybe... But specifically in my case, the excel file is exported from a web
> page. I think there should be a way to read the content as a pure text.

What form are you getting the file in? Are you being given an
Excel file, or are you loading a text file into Excel?

The problem is that when it reads a csv file, Excel aggressively
turns anything it thinks looks like a number into a number, and
anything it thinks looks like a date into a date.

There are ways to avoid that, but they all rely on having access
to the csv file before loading it into Excel. Once it's in Excel,
the data has already been corrupted and there's nothing you can do
about it.

If you have access to the original data as a csv file or some
other text format, I would suggest eliminating Excel altogether
and just read the original file with Python.

-- 
Greg



More information about the Python-list mailing list