How To: Import CSV into Base Table

Discuss the database features
Post Reply
dalivad
Posts: 2
Joined: Wed Dec 29, 2010 6:55 pm

How To: Import CSV into Base Table

Post by dalivad »

How does one import a CSV file into an OOBase Table?

This is easily done in Access (used at school & work), but I cannot a method for doing so with OOBase at home.

Thanks.

rmfr
OpenOffice 3.1 on Windows Vista
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How To: Import CSV into Base Table

Post by FJCC »

Here are two methods:
1. Import the CSV data into Calc. Select and copy all of the data. In the Base file, go to the Tables view (that is, click the Tables icon in the left had section), right click in the region where the tables are listed and select Paste. In the dialog that pops up, choose Definition and Data, then fill out the subsequent screens as needed.
2. Using csv/text files as editable data source.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How To: Import CSV into Base Table

Post by Villeroy »

FJCC wrote:Here are two methods:
1. Import the CSV data into Calc. Select and copy all of the data. In the Base file, go to the Tables view (that is, click the Tables icon in the left had section), right click in the region where the tables are listed and select Paste. In the dialog that pops up, choose Definition and Data, then fill out the subsequent screens as needed.
2. Using csv/text files as editable data source.
3. Store all similar csv files in one directory and connect a Base document to this directory.

Option 1 copies spreadsheet data into some type of editable database (native HSQLDB, MySQL or whatever database you connect Base with).
Option 2 utilizes some database server's capability to load plain text into predefined tables.
Option 3 treats a collection of plain text files as if they were tables of a read-only database. From this pseudo-database you may also copy selected data into a true database.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Pondy
Posts: 1
Joined: Tue Oct 09, 2012 3:16 am

Re: How To: Import CSV into Base Table

Post by Pondy »

I encountered this problem and found a workaround. When copy and pasting in from Calc to Base to create a new table, when you get prompted to let Base create an automatic key for you, pick Yes. Once that is successful, edit the table, selecting the fields to be part of your compund key and then right-click, Primary Key. This takes the little key icon off of the autogenerated field and moves it to your intended key fields. Right-click and delete the autogenerated field since you didn't really want it in the first place. Save. It warns you that you just deleted the primary key, but tell it to Yes go ahead and do that. Voila. Edit the table again and you will see that the new compound key is just how you want it. I think this is somehow related to the creation of the system-generated index required behind any primary key. I think it fails to create the index unless you answer the automatic key question with Yes. Once that system-generated index is created for the temporary key, Base is able to modify the already-created index definition when you change what fields are to be the key.
OpenOffice 3.4.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How To: Import CSV into Base Table

Post by Villeroy »

Pondy wrote:I encountered this problem and found a workaround.
Which problem? And why such a complicated workaround? What kind of "Base table" do you mean? I do not see any of the data you are processing, so your "workaround" may work for you but fail for anybody else.

A simple csv record like the following 3 fields in one line ...

Code: Select all

2011-12-31,3.14159,"Some text with ""quotes"" behind a date and a decimal."
... can be used easily in 3 different ways. It can be linked to a text table of a real database, it can be copied into the table of a real database, it can be linked to a Base document without using any real database.
Whatever your "workaround" works around, it demonstrates that you dabble around with things you did not understand yet. No, database development can not be easy nor "intuitive". But the result should be.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply