Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I want to read a .xlsx file using the Pandas Library of python and port the data to a postgreSQL table. 

All I could do up until now is:

import pandas as pd

data = pd.ExcelFile("*File Name*")

Now I know that the step got executed successfully, but I want to know how i can parse the excel file that has been read so that I can understand how the data in the excel maps to the data in the variable data. 

I learnt that data is a Dataframe object if I'm not wrong. So How do i parse this dataframe object to extract each line row by row.

1 Answer

0 votes
by (41.4k points)

ANSWER

To read a .xlsx file, create a dictionary containing a DataFrame for every sheet:

xl_file = pd.ExcelFile(file_name)

dfs = {sheet_name: xl_file.parse(sheet_name) 

          for sheet_name in xl_file.sheet_names}

Related questions

Browse Categories

...