I am using H2 DB in my java application. I want to load a .csv file to the DB. This file contains column headers as the first line of the file. So while loading the file into the DB through CSVREAD
command, H2 is trying to parse the first line also and thus failing.
So how to skip loading the first line. Below the query I am using to load the file to the DB:
"CREATE TABLE TEST (CIRCLE VARCHAR_IGNORECASE(50), MSISDN VARCHAR_IGNORECASE(50), PORT_IN_DATE TIMESTAMP, OPERATOR VARCHAR_IGNORECASE(255), PRODUCT_TYPE VARCHAR_IGNORECASE(255), PORT_ID VARCHAR_IGNORECASE(255)) AS SELECT * FROM CSVREAD('src/test/resources/test.csv', "
The CSVREAD function supports both files with and without column header. If the file contains a column header, then don't supply the column list in the function, for example:
SELECT * FROM CSVREAD('test.csv');
SELECT * FROM CSVREAD('data/test.tsv', null, 'rowSeparator=' || CHAR(9));
and if the file doesn't contains the column header, then supply the column list in the function call, for example:
SELECT * FROM CSVREAD('test2.csv', 'ID|NAME', 'charset=UTF-8 fieldSeparator=|');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With