How to read a .xlsx file using the pandas Library in iPython?

前端 未结 6 454
生来不讨喜
生来不讨喜 2020-11-28 02:27

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:

im         


        
6条回答
  •  情歌与酒
    2020-11-28 03:23

    from pandas import read_excel
    # find your sheet name at the bottom left of your excel file and assign 
    # it to my_sheet 
    my_sheet = 'Sheet1' # change it to your sheet name
    file_name = 'products_and_categories.xlsx' # change it to the name of your excel file
    df = read_excel(file_name, sheet_name = my_sheet)
    print(df.head()) # shows headers with top 5 rows
    

提交回复
热议问题