Relational Databases - An Example - Importing Data

This page follows on from database example page.

I found some data, in order to get it into the database I first edited it so that it is in CSV (Comma Separated Variable) format.

I have put a copy here: nutrition.csv

This is a text format where each field is in quotes and separated by commas. Each entry is on a separate line.

csv file

First I started OpenOffice.org Calc program and opened the CSV file, this brings up the following dialog box:

calc select

This should be set to separate with comma, then press OK, then select all the elements we want to include in the database, press edit->copy or control-c to copy to clipboard.

calc select

Leave the Calc program (don't exit) and start Open Office.org Base program. This brings up the following Wizard:

Leave set to "Create a new database" and click on next:

base2

Leave the above default values and click on finish:

base3

Enter name of database and click on OK which brings up the following screen:

base4

In the Database pane click on 'Tables':

base5

Click on the Tables pane and while the cursor is in the Tables pane type control-v. this brings up the following

copy 1

Set the table name and also set 'Create primary key' then press next

Click on '>>' to select all columns and click on next:

copy 3

I modified the length of type, barcode and hydrodised to 50.

The fields energykj, energykc, protein, carb, sugar, fat, saturates, fibre and sodium to:

Field Type Double
Length 17
Decimal Places 0

I could not change the Decimal places from 0, I assume this allows any value.

Clicking on Create shows the byWeightQuantities table:

base 6

The Calc program can now be exited leaving the base program loaded with the data.

Next stage - go on to: Setting up a form

Other sections are:

Data:


metadata block
see also:

 

 

Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.