Kùzu C++ API
Loading...
Searching...
No Matches
csv_reader_config.h
Go to the documentation of this file.
1#pragma once
2
3#include "constants.h"
4#include "copy_constructors.h"
5#include "value.h"
6
7namespace kuzu {
8namespace common {
9
10struct CSVOption {
11 // TODO(Xiyang): Add newline character option and delimiter can be a string.
16 uint64_t skipNum;
17
19 : escapeChar{CopyConstants::DEFAULT_CSV_ESCAPE_CHAR},
20 delimiter{CopyConstants::DEFAULT_CSV_DELIMITER},
21 quoteChar{CopyConstants::DEFAULT_CSV_QUOTE_CHAR},
22 hasHeader{CopyConstants::DEFAULT_CSV_HAS_HEADER},
23 skipNum{CopyConstants::DEFAULT_CSV_SKIP_NUM} {}
25
26 // TODO: COPY FROM and COPY TO should support transform special options, like '\'.
27 std::string toCypher() const {
28 std::string header = hasHeader ? "true" : "false";
29 return stringFormat("(escape ='\\{}', delim ='{}', quote='\\{}', header={})", escapeChar,
30 delimiter, quoteChar, header);
31 }
32
33private:
34 CSVOption(const CSVOption& other)
36 hasHeader{other.hasHeader}, skipNum{other.skipNum} {}
37};
38
42
43 CSVReaderConfig() : option{}, parallel{CopyConstants::DEFAULT_CSV_PARALLEL} {}
45
46 static CSVReaderConfig construct(const std::unordered_map<std::string, common::Value>& options);
47
48private:
50 : option{other.option.copy()}, parallel{other.parallel} {}
51};
52
53} // namespace common
54} // namespace kuzu
std::string stringFormat(std::string_view format, Args... args)
Definition string_format.h:99
Definition alter_type.h:5
Definition csv_reader_config.h:10
char escapeChar
Definition csv_reader_config.h:12
CSVOption()
Definition csv_reader_config.h:18
bool hasHeader
Definition csv_reader_config.h:15
char quoteChar
Definition csv_reader_config.h:14
std::string toCypher() const
Definition csv_reader_config.h:27
EXPLICIT_COPY_DEFAULT_MOVE(CSVOption)
char delimiter
Definition csv_reader_config.h:13
uint64_t skipNum
Definition csv_reader_config.h:16
Definition csv_reader_config.h:39
CSVReaderConfig()
Definition csv_reader_config.h:43
CSVOption option
Definition csv_reader_config.h:40
bool parallel
Definition csv_reader_config.h:41
EXPLICIT_COPY_DEFAULT_MOVE(CSVReaderConfig)
static CSVReaderConfig construct(const std::unordered_map< std::string, common::Value > &options)
Definition constants.h:124