Search code examples
sqllinuxlibreofficepgadmin

LibreOffice calc to PGAdmin 3?


I have one table with 9 columns and 1010 rows. Now, I want to turn this table into SQL database so I can manipulate data from PGAdmin 3?

I literally only need an option to export LibreOffice Calc file into SQL file or PGAdmin 3 readable file? What's the best way to do this?


Solution

  • In libre office calc save as and select the type as

    csv

    Then create the table and column types in Postgresql (psql) / Pgadmin

    Then import (right click on table select import)

    Just one word of warning if you create primary key and have columns or rows empty this will fail.

    Works fine. Tried and tested.

    Here's a simple example

    12  Alison  Norton  road    district    nr20    10  12.4
    13  Bob     Down    road    district    nr6     11  0.4
    14  karen   milf    road    district    nr20    200 9
    

    CREATE TABLE test1 ( "Import-id" integer PRIMARY KEY, fname character(10), lname character(10), add1 character(10), add2 character(10), zip1 character(10), aint integer, amoney money ) WITH ( OIDS=FALSE ); ALTER TABLE test1 OWNER TO postgres;

    You can either use this command

    copy your_created_table FROM '/your/path/to/file.csv' USING DELIMITERS ',' CSV;
    

    Or you can right click on the table and use the import function as shown below

    Pgadmin import menu

    Don't forget to change the type from text to csv

    Pgadmin import wizard

    All the best hope this helps