3 ms·
You can use regexes to help you split the file into pieces (this is in PostgreSQL), I expect other dbms's to have similar functions available. SELECT
by feike 5y ago
You can use regexes to help you split the file into pieces (this is in PostgreSQL), I expect other dbms's to have similar functions available.
SELECT
lineno::int AS line,
((lineno-3)/6)::smallint AS card,
((lineno-3)%6)::smallint AS y,
(col - 1)::smallint AS x,
value::smallint AS value
FROM
regexp_split_to_table($1, '\n') WITH ORDINALITY AS sub(line, lineno)
CROSS JOIN
regexp_split_to_table(ltrim(line, ' '), '(\s+|,)') WITH ORDINALITY AS sub2(value, col)
WHERE
line != ''
AND value != ''
- vimsee 5y agoI did not know about regexp_split_to_table() or regex functions in general in dbms, but that is very neat.