An example of how to load data from a CSV file into a new Hyper file.
#include <iostream>
#include <string>
"Customer",
static void runCreateHyperFileFromCSV() {
std::cout << "EXAMPLE - Load data from CSV into table in new Hyper file" << std::endl;
const std::string pathToDatabase = "data/customer.hyper";
{
std::unordered_map<std::string, std::string> processParameters = {
{"log_file_max_count", "2"},
{"log_file_size_limit", "100M"}};
{
std::unordered_map<std::string, std::string> connectionParameters = {{"lc_time", "en_US"}};
std::string pathToCSV = "data/customers.csv";
std::cout << "Issuing the SQL COPY command to load the csv file into the table. Since the first line" << std::endl;
std::cout << "of our csv file contains the column names, we use the `header` option to skip it." << std::endl;
int64_t rowCount = connection.executeCommand(
" with (format csv, NULL 'NULL', delimiter ',', header)");
std::cout << "The number of rows in table " << customerTable.getTableName() << " is " << rowCount << "." << std::endl;
}
std::cout << "The connection to the Hyper file has been closed." << std::endl;
}
std::cout << "The Hyper Process has been shut down." << std::endl;
}
int main() {
try {
runCreateHyperFileFromCSV();
return 1;
}
return 0;
}