It:Creare una tabella da un foglio elettronico

From NeoWiki

Revision as of 21:26, 6 August 2007 by Valterb (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search
Questo articolo fa parte della serie di articoli Verso Base e Ritorno.

Per il diario ornitologico abbiamo bisogno di una tabella che elenchi tutti gli uccelli che potremmo vedere nella nostra area. Creare la tabella da zero potrebbe essere noioso e richiede una grande quantità di tempo. Fortunatamente i dati di cui abbiamo bisogno sono già disponibili in un formato che possiamo usare. La { American Ornithologists' Union} fornisce il proprio elenco di uccelli (in inglese) visibile nell'area AOU (America Settentrionale e Centrale) in un file Excel. Questo articolo descrive come prendere questi dati da un file di Excel per metterli nel nostro database per il diario ornitologico.


Importare fogli elettronici è diverso da Connettersi ad essi

NeoOffice Basepuò usare i dati presenti in un foglio elettronico in due modi differentis. Una delle opzioni prevede la possibilità di "connettersi" ad un foglio elettronico esistente. Questo metodo viene descritto nel'articolo It:Usare un foglio elettronico di Calc come sorgente di dati. Quando si usa questo metodo i dati possono essere modificati solo all'interno del foglio elettronico sorgente; i dati non possono essere modificati dall'interno di Base.

L'altra opzione è di "importare" i dati dal foglio elettronico in un documento Base. In questo modo i dati possono essere modificati in Base (il foglio elettronico originale non subirà alcuna alterazione quando i cambiamenti vengono fatti in Base). Nel nostro caso oi vogliamo proprio importare i dati, ma il foglio elettronico ha bisogno, prima, di una aggiustatina.

Formattare il Foglio Elettronico

Before importing the data, we need to make sure that it is correctly formatted.

The first row of the data range (not necessarily of the document) should contain the field names. Any fields that must not be empty need to have data in them. In the case of the AOU list, a careful inspection will show that the Order, Family, Subfamily, and genus fields only contain data for the first record with that order, family, subfamily, or genus. In our database, this information needs to be in each record. To fix this:

Click in a cell that contains an Order (or Family, etc.) name. The cell border becomes black, and a small back square is visible in the lower right hand corner of the cell.
Drag this square downward; as you do so, a red border drags with you. Keep dragging until the border encompasses all of the empty cells, up to but not including the next cell with text in it, then release the mouse button. The empty cells with the text content of the first cell.

The order of the AOU checklist a standard order, used in birding books and checklists. To ensure that we can reproduce this order in the database, it would be wisest to add an ID field, with the first record given the number 1, the next 2, etc. To do so:

Insert a new column to the left of Column A (click on column A and then choose Columns from the Insert menu.
Type <>ID<> into the cell in new column A just to the left of the cell labeled <>order<>
Type a <>1<> into the first cell under <>ID<>:
Follow the instructions on the Selecting and Filling a Cell Range wiki page to fill the column so that each cell contains a number one greater than the one above it. (i.e. 1, 2, 3, etc.)

I also changed some of the field names, especially those that were originally just one letter; adjust these names as you see fit.

Importing the Data

We are now ready to import the data.

Select the entire range of the data, including the row with column names. The easiest way to do this is probably to click in the upper left hand cell of the range (probably the cell labeled ID), then scroll down to the last row of data and Shift-click in the far right hand cell of the range.
Copy this selected range
Open the Birder's journal database
Click on the Tables icon in the Database column on the right.
In the lower rectangular area, labled Tables, right-click or control-click in the white space. (If there is an existing table, make sure not to click on it).
In the contextual menu that comes up, choose Paste. The Copy Table window appears.
Give the table a name in the Table Name field; I chose AOU Birdlist.
Make sure the Definition and Data radio button is marked
Because we added an ID field while prepping the spreadsheet, we want to leave the Create primary key checkbox unchecked. If you were importing data that did not already include a primary key field, you would want to check this box.
Click Next
The Apply columns that appears allows you to choose which fields you want to import. In our case we want to import all of them, so you can click on the >> button.
Then click Next
The Type Formatting window appears. Highlight each field in turn in the vertical column to the left, and adjust the Field Name, Field Type, Entry Required, and Length settings as needed.
In this table, all the fields are TEXT except for the ID field, whose field type should be INTEGER.
Most of the Lengths are ok, although the Hawaii, Introduced, Accidental, and Nonbreeding could be reduced to a length of 5 or so, since the data in those columns is genrally only one character.
The ID and English Name fields should be marked for Entry Required.
Once the fields are properly defined, click on Create

Note: Make certain that all the field definitions are correct before clicking Create. Attempting to change field types, lengths, etc. later will destroy data in those fields.

A No primary key warning window will appear. Click No. We will identify the primary key in a moment.

Once the new table has appeared in the Tables Section of the document window, right-click or control-click on the new table. Select Edit from the contextual menu. The table opens in design view.

Click on the line containing the ID field. A green flippy triangle appears in the "cell" to the left of the word ID
control-click or right-click on the green triangle and choose Primary Key from the contextual menu. A key icon appears in the box
Click on the disk-drive icon in the toolbar to save your changes, then close the window.

You have successfully imported data from a spreadsheet.

Related Wiki Articles

Using a Calc spreadsheet as a data source

Related External Links

Bringing data into OpenOffice 2.0's database

An article from Solveig Haugland on importing data.

Questo articolo in altre lingue: English
Personal tools