How To: Import CSV into Base Table

Discuss the database features

How To: Import CSV into Base Table

Postby dalivad » Wed Dec 29, 2010 7:15 pm

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
dalivad
 
Posts: 2
Joined: Wed Dec 29, 2010 6:55 pm

Re: How To: Import CSV into Base Table

Postby FJCC » Wed Dec 29, 2010 7:54 pm

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.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7443
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How To: Import CSV into Base Table

Postby Villeroy » Wed Dec 29, 2010 9:26 pm

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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27572
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How To: Import CSV into Base Table

Postby Pondy » Tue Oct 09, 2012 3:30 am

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
Pondy
 
Posts: 1
Joined: Tue Oct 09, 2012 3:16 am

Re: How To: Import CSV into Base Table

Postby Villeroy » Wed Oct 10, 2012 12:18 pm

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   Expand viewCollapse view
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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27572
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Base

Who is online

Users browsing this forum: No registered users and 4 guests