Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

Try this recursive query which is linear-time in input (timing study herehere)

trie = Query[GroupBy@First, If[First@# == {}, {}, trie@#] &, Rest];

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

Assume filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} :

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][trie]

Try this recursive query which is linear-time in input (timing study here)

trie = Query[GroupBy@First, If[First@# == {}, {}, trie@#] &, Rest];

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

Assume filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} :

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][trie]

Try this recursive query which is linear-time in input (timing study here)

trie = Query[GroupBy@First, If[First@# == {}, {}, trie@#] &, Rest];

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

Assume filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} :

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][trie]
deleted 63 characters in body
Source Link
alancalvitti
  • 15.2k
  • 3
  • 27
  • 93

Try this recursive query which is linear-time in input (timing study here)

prefixTrietrie := Query[GroupBy[First]Query[GroupBy@First, If[First[#]If[First@# == {}, First[#]{}, byPrefix[#]]trie@#] &, Rest]Rest];

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

For simplicity the above assumesAssume filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} after import:

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][prefixTrie]&][trie]

Try this recursive query which is linear-time in input (timing study here)

prefixTrie := Query[GroupBy[First], If[First[#] == {}, First[#], byPrefix[#]] &, Rest]

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

For simplicity the above assumes filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} after import:

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][prefixTrie]

Try this recursive query which is linear-time in input (timing study here)

trie = Query[GroupBy@First, If[First@# == {}, {}, trie@#] &, Rest];

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

Assume filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} :

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][trie]
deleted 13 characters in body
Source Link
alancalvitti
  • 15.2k
  • 3
  • 27
  • 93

Try this recursive query which is linear-time in input (timing study here)

prefixTrie := 
 Query[GroupBy[First], If[First@#If[First[#] == {}, First@#First[#], byPrefix[#]] &, 
  Rest]

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

For simplicity the above assumes filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} after import:

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][prefixTrie]

Try this recursive query which is linear-time in input (timing study here)

prefixTrie := 
 Query[GroupBy[First], If[First@# == {}, First@#, byPrefix[#]] &, 
  Rest]

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

For simplicity the above assumes filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} after import:

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][prefixTrie]

Try this recursive query which is linear-time in input (timing study here)

prefixTrie := Query[GroupBy[First], If[First[#] == {}, First[#], byPrefix[#]] &, Rest]

Variations on the above are possible and useful (see Antonov's Trie page here developed in 2013 but without Dataset).

For simplicity the above assumes filenames have been split into path component lists, eg "a/b/c" --> {"a","b","c"} after import:

flatFiles = FileNames["*.gsheet", "~/Google Drive/...", Infinity] // Dataset

Then:

flatFiles[All, StringSplit[#, "/"] &][prefixTrie]
Source Link
alancalvitti
  • 15.2k
  • 3
  • 27
  • 93
Loading