alex smolyakov
alex smolyakov

Reputation: 318

Non-standard Excel file to csv or pandas

enter image description here

I'm stuck with this problem, I have an Excel file and I want to convert to csv or pandas dataframe. But I don't even understand how to start with it? Any help will be appreciated.

I think it will be easier to understand from screenshot.

Upvotes: 0

Views: 169

Answers (1)

Massimo Rebuglio
Massimo Rebuglio

Reputation: 341

Pandas is made to store "standard" datasets, i.e. a "simple table" with headers and value.

You need a more generic tool, like openpyxl.

Example taken here:

from openpyxl import load_workbook
def get_cell_info(path):
    workbook = load_workbook(filename="yourfile")
    sheet = workbook.active
    print(sheet)
    print(f'The title of the Worksheet is: {sheet.title}')
    print(f'The value of A2 is {sheet["A2"].value}')
    print(f'The value of A3 is {sheet["A3"].value}')
    cell = sheet['B3']
    print(f'The variable "cell" is {cell.value}')

Upvotes: 1

Related Questions