Transform and load big data CSV files into a database
Generate the files, transform them using SQLite, and load them to a Db2 for z/OS database using zload
This code pattern shows you how to generate a set of CSV files, transform them using a tool called SQLite, and load them to a Db2 for z/OS database using a JDBC function called zload.
This work was done as part of the Example Health set of code patterns, which demonstrate how cloud technology can access data stored on z/OS systems. We needed a way to generate a large amount of patient health care data to populate the Db2 for z/OS database. We found an open source tool called Synthea that generates the kind of synthentic data we wanted.
The Synthea CSV files needed to be transformed to match the table schemas used in the Example Health application. We found a public domain tool called SQLite which made these transformations easy.
Finally, the transformed CSV files needed to be loaded from a distributed workstation into the Db2 for z/OS database. We used a JDBC function called zload to accomplish this. zload requires Db2 for z/OS version 12.
A shell script (
run.bat) drives the processing. There are four main steps as shown below.
- The Synthea tool is called to generate a set of CSV files containing synthesized patient health care data.
- A JDBC program is called to determine the current maximum patient number in the DB2 for z/OS database.
- The SQLite program is called to transform the CSV files produced by Synthea to match the schema of the DB2 for z/OS database.
- A JDBC program is called to load the transformed CSV files into the DB2 for z/OS database tables.
Find the detailed steps for this pattern in the README file. The steps show you how to:
- Install the required tools.
- Clone and build the project.
- Clone and build the Synthea project.
- Change the properties in synthea/src/main/resources/synthea.properties as necessary.
- Create the DB2 for z/OS database.
- Set up environment variables that the script requires to connect to your DB2 for z/OS database.
- Run the script from the project with the current directory set to the Synthea project.