0

I have checked some links how to load data from excel file into PostgreSQL table. There are solutions as:

  • Save excel to .CSV file and use COPY command.
  • Use Python script to read and insert data to Postgresql.

Because of the format of excel file, I can't save it as CSV file. Do we have any built-in functions PostgreSQL provided to read data from excel file?

Thai Le
  • 13
  • 2
  • 11
  • "Because of the format of excel file..." What does it mean? Does your excel contains formulas, images, charts...? In that case, you will have to make the parser of your own, or use some of the solutions that are already available on the internet (if it suits you) like SSIS PowerPack. There's also some parsers available on github like this one: https://github.com/xoykreme/x2db – user5214530 Dec 24 '19 at 06:55
  • if you can save it as csv then https://stackoverflow.com/questions/20039856/import-excel-data-into-postgresql-9-3 use it. – Bharti Mohane Dec 24 '19 at 07:32
  • you can try with ... https://stackoverflow.com/questions/59299987/how-do-i-take-only-specified-required-columns-from-csv-file-and-add-into-a-table/59301886#59301886 – Zakir Hossain Dec 24 '19 at 08:38
  • `psql` has nothing built-in (nor does Postgres itself). This is usually provided by the SQL client you are using, many SQL clients offer direct Excel import –  Dec 24 '19 at 09:38
  • Now I have developed python script to populate data into database by using Pandas module. – Thai Le Dec 26 '19 at 13:32

2 Answers2

0

I don't think there is something built in to read xlsx file, maybe you should modify your case to work with either solution.

0

In Excel, you could make an ODBC connection with PostgreSQL, then send SQL commands to insert data from Excel to PostgreSQL.

PaichengWu
  • 2,649
  • 1
  • 14
  • 28