(no title)
feike | 4 years ago
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|4 years ago