HRDIODB
[ class tree: HRDIODB ] [ index: HRDIODB ] [ all elements ]
Prev Next
Using the CSV Uploader

Using the CSV Uploader

Table of Contents

Instructions

Data 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 file

Create a CSV file that follows this example:

  1. table
  2. HRDI_Days
  3. fields
  4. UARS_DayFlight_DirectionBeta_Angle
  5. 4835Backward-12.83
  6. 4836Backward-16.99
  7. 4837Backward-21.21
  8. 4838Backward-25.46
  9. 4839Backward-29.74
  10. 4840Backward-34.05
  11. 4841Backward-38.38
  12. 4842Backward-42.72
  13. 4843Backward-47.06
  14. 4844Backward-51.41
  15. 4845Backward-55.73
  16. table
  17. HRDI_Modes
  18. fields
  19. UARS_DayProcess_IDAzimuth1Azimuth2Azimuth3Azimuth4
  20. 483537-45-13545135
  21. 483561 , , , ,
  22. 483637-45-13545135
  23. 483661 , , , ,
  24. 483737-45-13545135
  25. 483761 , , , ,
  26. 483836-45-13545135
  27. 483845-45-13545135
  28. 483837-45-13545135
  29. 483936-45-13545135
  30. 483945-45-13545135
  31. 483937-45-13545135
  32. 484036-45-13545135
  33. 484045-45-13545135
  34. 484037-45-13545135
  35. 484136-45-13545135
  36. 484145-45-13545135
  37. 484137-45-13545135
  38. 484236-45-13545135
  39. 484245-45-13545135
  40. 484237-45-13545135
  41. 484336-45-13545135
  42. 484345-45-13545135
  43. 484337-45-13545135 
  44. 484436-45-13545135
  45. 484445-45-13545135
  46. 484437-45-13545135 
  47. 484536-45-13545135
  48. 484545-45-13545135
  49. 484537-45-13545135

Step 2: Copy CSV file

Copy 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 uploader

From 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

Documentation generated on Tue, 23 Jan 2007 22:57:40 -0500 by phpDocumentor 1.3.0RC6