
In this step we are going to define the structure of the customers database table and add the SQL DDL statement to create the table in PostgreSQL database. If we open the csv file saved earlier in text editor it will look like the following image.Ģ- Define the structure of the PostgreSQL database table and create it. Now we have prepared the CSV file which will be used by PostgreSQL COPY statement to load the data into database table. Īn options dialog appears in this dialog select “,” as Field delimiter and choose “ as a String delimiter and hit OK button. Open the spreadsheet file that contains the data you want to save as CSV in the LibreOffice Calc and then menus choose File → Save As …įrom the Save File dialog add the file name then choose the Text CSV from format, the following image shows this step.Ī confirmation message pops up choose use “Text CSV Format”. Here (in this tutorial) I’m using LibreOffice Calc you can use Microsoft Excel or any other spreadsheet application you prefer and you will find options corresponding to those used in this example with LibreOffice Calc.

We are going to save the data exists in this spreadsheet into CSV format (Comma Separated Values). Suppose that we have a spreadsheet file contains customers information with the following structure

Note that you can skip this step if you already have the data in CSV file format.

ġ- Prepare the spreadsheet (Excel - LibreOffice calc) file and convert it to CSV format.

In this tutorial we will import data from spreadsheet (Excel, LibreOffice Calc) file into PostgreSQL database table using PostgtreSQL SQL COPY command.įor PostgreSQL 9.0 or heigher.
