I am tasked with storing my company’s data in a database and I am using PostgreSQL. I am using python to access and interact with PostgreSQL. My issues so far is that I have multiple excel datasets that are quite complex and large with multiple sheets (i.e. up to 20 sheets per excel file). These are each in "xlsx" format and I am trying to get them in "csv" to input into tables in the database. I tried using pandas to convert to csv and it converted each excel file to csv format. However, there were many NaN values, an unnamed column added and the output csv file’s columns did not correlate to its associated rows of data. It became very messy and incorrectly organized.
Any ideas on how I can: Convert from "xlsx" to "csv" with excel files that have multiple sheets?
Thanks!
I tried using pandas to convert the excel "xlsx" files into "csv" files. I got outputs of csv files, however, upon opening it I saw an unnamed column added, NaN’s, and columns not corresponding to the rightly associated rows of data. In summary, the output csv file was very messy and not a correct depiction of the information contained in the original excel spreadsheets.
2
Answers
You use the below code pattern to load your data in excel sheet to postgres database
this will create files named
excel_file_path_sheet_name