python/postgres query

fnoyanisi at yahoo.com fnoyanisi at yahoo.com
Wed May 29 01:38:19 CST 2013


Just an idea...

If you are confident that you will aleays have the output in the format gave (i.e. folder listed first, then the sub folders), you can

- read first value an store it
- if next value string contains the first one, skip it otherwise store it as well (if the previous string is not included within this one, this must be a new folder)
- repeat this for all records

Just a quick (and dirty!) way

On 29/05/2013, at 1:03 AM, Spyro Polymiadis <spiz at spiz.no-ip.com> wrote:

> Hi folks, 
> 
> I have a python file querying a database to return a list of paths with output like:
> 
> /path/to/folder
> /path/to/folder/subfolder1
> /path/to/folder/othersubfolder2
> /path/to/folder2
> /path/to/folder/subfolder1
> /path/to/folder3
> /path/to/folder4
> …Etc
> 
> which is stored in a variable called 'paths'
> 
> How is it possible for me to go through the list – and remove all the entries with "subfolders"
> And only leave me with the "top level" 'folder' path?
> 
> What would be nicer is if there is an option I can add to my select statement in postgres to only return the right folders.
> 
> Any ideas welcome :)
> 
> Cheers
> Spyro
> 
> 
> -- 
> This message was scanned by ESVA and is believed to be clean.
> -- 
> LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.freenode.net
> To unsubscribe or change your options:
>  http://www.linuxsa.org.au/mailman/listinfo/linuxsa



More information about the linuxsa mailing list