0

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
DaX
  • 94
  • 1
  • 11
  • Hi Dax Can you give me a sample Eg a couple of rows. I might be able to help you. Also could you provide the types of data. Eg string, integer, float etc –  Mar 16 '16 at 16:58

1 Answers1

2

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

  • Thanks a lot for your answer. Unfortunately, i don't have CSV as option when trying to save from LibeOfficeCalc as you can see here: [link](http://imgur.com/pei8fNM) – DaX Mar 17 '16 at 08:01
  • 1
    Scoll down a little more Dax (The type scoll bar -> | ) Text .cvs is onefrom the bottom (use the arrow button if you like :) ).. I'll delete this comment afterwards. Only human :) –  Mar 17 '16 at 11:45
  • Hi @DaX Here's a link for you https://help.libreoffice.org/Calc/Importing_and_Exporting_CSV_Files –  Mar 17 '16 at 18:00
  • I've never seen someone being helpful as you are. Thanks a lot man! I really appreciate it! – DaX Mar 18 '16 at 09:21