0

I've got a few Excel sheets with columns with different data types. Some of them consist of formulas as well. Pandas does NOT read values from Excel cells with such simple formula as =10+10 or =250+30+40

Code like this

truck_work = pd.read_excel(hauls_monthly_data, sheetname=truck)

returns dataframe where column filled from those Excel cells consists data, which type is float and value is nan. But I'm waiting for float with value 10 and 320

The only way I've worked out yet to solve this issue is by manually saving each time an Excel-file before processing data from it. Which is not much Pythonic way of dealing with problems.

If I'm using such code as

wb = load_workbook(filename = hauls_monthly_data)
sheet_names = wb.get_sheet_names()
name = sheet_names[1]
sheet_ranges = wb[name]
truck_work = pd.DataFrame(sheet_ranges.values)

then it returns

8          =16+109+108        =6+40+29                None   

Any help be very appreciated.

Sergey Solod
  • 695
  • 7
  • 15
  • The question was marked as 'duplicate'. But I can't catch what is a reason? The topic which is mentioned above as an answer actually was about an attempt to read formulas not values. I'm not able to read data as I need instead. – Sergey Solod Sep 17 '18 at 07:38
  • Yeah, your problem is the inverse of the marked duplicate. This one might be a better match: – divibisan Sep 17 '18 at 20:38
  • Possible Duplicate of: https://stackoverflow.com/questions/22613272/how-to-access-the-real-value-of-a-cell-using-the-openpyxl-module-for-python?noredirect=1&lq=1 – divibisan Sep 17 '18 at 20:38
  • @divibisan Maybe I was not clear enough with my question. But the answer mentioned above does not consist of methods to solve my issue. Any of them. By using 'wb = load_workbook(filename = hauls_monthly_data)' I got '=16+109+108 ' for all cells with such data. If I use 'wb = load_workbook(filename = hauls_monthly_data, data_only=True)' then it returns 'None'. But I do need a float value of those cells, the result of that simple calculation which in this particular cell is 233. – Sergey Solod Sep 18 '18 at 05:33
  • 1
    Then you should edit your question to show what happens when you try the suggestions in the linked question. By editing your question it will be put in the `reopen` queue and will get reopened once people see how it is, in fact, different from that question – divibisan Sep 18 '18 at 15:02

0 Answers0