Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
thepope
Contributor II
Contributor II

Decoding a Directory structure

Hi,

 

I have a real brain teaser

I have table that lists the directory structure in a real bad way and would like some assistance in simplifying  the creation of a table show the folder structure in a tabular way ie; left to right on a single line.

root/
Root/Folder1
Root/Folder1/Folder1
Root/Folder1/Folder2
Root/Folder1/Folder2/Folder1

FolderID FolderName
|-1
|-1-|1 Folder1
|-1/1-|1 Folder1
|-1/1-|2 Folder2
|-1/1/2-|1 Folder1

 

The start and end are denoted by "|- and -|" a new folder is given a number after the "-|"

any guidance is appreciated 

Labels (1)
2 Replies
marcus_sommer

I'm not sure that I really understand what do you you want to do but I think I would try it with something like this:

load *, rowno() as RowNo;
load recno() as RecNo, iterno() as IterNo, String, subfield(String, Delimiter, iterno()) as SubString
from Source while substringcount(String, Delimiter) <= iterno();

Subfield() will split your String into multiple records. RecNo and RowNo enable you to track the source- and target-records and IterNo the respective depth of the SubString.

Before and afterwards you will probably need various string-operations with replace(), keepchar() and also left(), right(), mid() and similar functions to prepare the String and to correct the created SubString appropriate.

The next step could be to create a mapping-table of foldernames in regard to the depth of the SubString - maybe just loading the split-results with an appropriate where-clause - and then loading the result-table again and replacing the depth-information with the foldernames.

Afterwards this result could be string-aggregated with concat() to a complete path.

- Marcus

thepope
Contributor II
Contributor II
Author

Hi Marcus,

 

I'm juggling about a dozen things at the moment so thanks for the input, I did a quick run through using the above but had to stop at 500 million lines ( I think I missed something) I will try and look again later this week