Using the CSV Uploader Using the CSV Uploader
Table of Contents
InstructionsData may be batch loaded into the HRDI Database from properly formatted CSV
(Comma Separated Values) files. Most major spreadsheet applications can
read and save CSV formatted files. The CSV uploader will parse a file which
contains table names, field names, and data. The table names and field
names must correspond with names used in the HRDI database. Once parsed,
the data will be compared against the database to determine if it is new
data or an update already existing data. To make this determination an
associative array of tables and their unique keys is held in the
configuration file conf.php.
In order to upload a new table row with the value of a field being the
default NULL, either don't specify the specific field in the CSV file at
all, or specify it but make the value an empty string "". When the {@link
mcpear} class encounters a key (field) with an empty string as the value,
it unsets the key. This results in the field not being specified, which
will in turn tell MySQL to give the field the default value, in this case
NULL.
In order to upload an update to a table row and set the value of a field to
NULL, specify the field and make the value of the field the string
NULL or "NULL". Please note that the
check for the string "NULL" is CaSe SeNsItIve, so
"null" or "Null" will not work.
Step 1: Create CSV fileCreate a CSV file that follows this example:
table
HRDI_Days
fields
UARS_Day, Flight_Direction, Beta_Angle
4835, Backward, -12.83
4836, Backward, -16.99
4837, Backward, -21.21
4838, Backward, -25.46
4839, Backward, -29.74
4840, Backward, -34.05
4841, Backward, -38.38
4842, Backward, -42.72
4843, Backward, -47.06
4844, Backward, -51.41
4845, Backward, -55.73
table
HRDI_Modes
fields
UARS_Day, Process_ID, Azimuth1, Azimuth2, Azimuth3, Azimuth4
4835, 37, -45, -135, 45, 135
4835, 61 , , , ,
4836, 37, -45, -135, 45, 135
4836, 61 , , , ,
4837, 37, -45, -135, 45, 135
4837, 61 , , , ,
4838, 36, -45, -135, 45, 135
4838, 45, -45, -135, 45, 135
4838, 37, -45, -135, 45, 135
4839, 36, -45, -135, 45, 135
4839, 45, -45, -135, 45, 135
4839, 37, -45, -135, 45, 135
4840, 36, -45, -135, 45, 135
4840, 45, -45, -135, 45, 135
4840, 37, -45, -135, 45, 135
4841, 36, -45, -135, 45, 135
4841, 45, -45, -135, 45, 135
4841, 37, -45, -135, 45, 135
4842, 36, -45, -135, 45, 135
4842, 45, -45, -135, 45, 135
4842, 37, -45, -135, 45, 135
4843, 36, -45, -135, 45, 135
4843, 45, -45, -135, 45, 135
4843, 37, -45, -135, 45, 135
4844, 36, -45, -135, 45, 135
4844, 45, -45, -135, 45, 135
4844, 37, -45, -135, 45, 135
4845, 36, -45, -135, 45, 135
4845, 45, -45, -135, 45, 135
4845, 37, -45, -135, 45, 135
Step 2: Copy CSV fileCopy your CSV file to the web server. You can do this by whatever
means you have available; scp, sftp, ftp, etc.
Step 3: Run CSV uploaderFrom a shell on the webserver, change to the hrdi base directory (eg. "cd
/var/www/hrdi/") and run:
php upload_csv.php FILENAME
| Prev |
|
Next |
| Cascading Style Sheets |
|
Third Party Libraries |
|
|