I have a SQLite table:
fileId | path
1 /video/gopro/father/mov001.mp4
2 /pictures/family/father/Oldman.jpg
3 /documents/legal/father/estate/will.doc
I want to separate this directory structure into a new Table with new Columns. New table:
fileId | path0 | path1 | path 2 | path3 | path4 .... (Define an upper limit of sub-dirs)
1 video gopro father mov001.mp4
2 pictures family father Oldman.jpg
3 documents legal father estate will.doc
What's the best approach? As a start, I have separated the strings by character "/" but currently this only makes new rows, not columns:
WITH split(Path, str) AS (
SELECT '', Path||'/' FROM listfile
UNION ALL SELECT
substr(str, 0, instr(str, '/')),
substr(str, instr(str, '/')+1)
FROM split WHERE str !=''
) SELECT Path FROM split WHERE Path!='' ;