Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Datasources can also be configured to retrieve data from CSV (comma-separated values) files, by using the text tables feature of HSQLDB.

 

Here's a short tutorial on how to achieve this. 

1.For this example we will use a simple csv file (named sample.csv and located in D:\hsql folder) with the following content:

...

The sample script creates user sa and grants access for connecting to the hsql schema, it creates the corresponding hsql text table for the csv file and sets the csv file source for populating the table (in our example located in the same folder as the script).

 

Info

Note the ignore_first=true option in the SET TABLE SOURCE statement from the script. It tells HSQLDB to ignore the first line in a file.

This option is used when the first line of the file contains column headings, as it is in our case. If you remove the column headings from the csv file, you also have to remove this option from the script.

...

5. Use your database custom fields with values populated from the csv files.

 

Other Methods of Loading CSV Data

...

Modern databases have the ability of mounting a CSV file as an individual table, which can be, after that, queried. Please refer to your database documentation or ask your DBA about it.

...