Load a simple csv
This guide shows how to load a CSV file into a store thanks to a CSV source.For a description of what the CSV Source is, refer to the CSV source.
Goal
The goal is to load the first two columns of “trades.csv” file into theTrades store.
File content
Trades content
We want to load the first two columns into Trades store.
Build a source
First step, in order to load a CSV file into a datastore, is to build a CSV source.They are associated to a parser configuration. Let’s build this parser configuration.
Trades store.Because of this simple mapping the name of the store is used as a topic name. This topic is registered into the source.
Load into datastore
Second step is to create a channel and use the source to fetch the data into the Datastore.A channel is the link between a topic and a store.
You can build a channel factory like this.
Source loads topic content using the channel and stream it into the Datastore.
There is two ways of doing so. Using the fetch utility :
ICSVSource is an AutoCloseable resource.Closing a source closes all the registered topics.
Load with a calculated column
Goal
The goal is still to load the same file into theTrades store, but we want to compute a new column from the
amount column.
Expected trade content
Load into the datastore
To add a new column which is based on existing ones we use anIColumnCalculator.