Zack Macomber
Zack Macomber

Reputation: 6905

Read using CSVREAD with non-printing characters as field and record separators

I have a file that I would like to read in H2 that uses FIELD(ASCII code 31) & RECORD(ASCII code 30) as the field and record separators in my file. I've tried this but it's not working...

SELECT * FROM CSVREAD('test.csv', null, 'rowSeparator=' || CHAR(30) || 'fieldSeparator=' || CHAR(31));

How do I need to format this to read from my file?

EDIT I

This parses the fields out correctly but the rows aren't being parsed out...not sure why:

SELECT * FROM CSVREAD('C:\Users\zmacomber\ReceiptPrinter\data\bak\address.dat', null, STRINGDECODE('charset=UTF-8 rowSeparator=' || CHAR(30) || ' fieldSeparator=' || CHAR(31)));

Upvotes: 0

Views: 390

Answers (1)

Thomas Mueller
Thomas Mueller

Reputation: 50107

Looking at the source code of the CSV tool, unfortunately you can not currently change the row separator used for reading (parsing). The row separator is only used for writing, not for reading. For reading, you would need to use \n, \r, or a combination of both.

I understand this is unexpected, but that's the way it currently is.

Upvotes: 1

Related Questions