sync databse table based on current directory data without losign previous values

nagia.retsina at gmail.com nagia.retsina at gmail.com
Wed Mar 6 17:09:23 CET 2013


Τη Τετάρτη, 6 Μαρτίου 2013 4:04:26 μ.μ. UTC+2, ο χρήστης Michael Ross έγραψε:
> On Wed, 06 Mar 2013 12:52:00 +0100, Mark Lawrence  
> 
> <breamoreboy at yahoo.co.uk> wrote:
> 
> 
> 
> > On 06/03/2013 07:45, Νίκος Γκρ33κ wrote:
> 
> >> I'am using this snipper to read a current directory and insert all  
> 
> >> filenames into a databse and then display them.
> 
> >>
> 
> >> But what happens when files are get removed form the directory?
> 
> >> The inserted records into databse remain.
> 
> >> How can i update  the databse to only contain the existing filenames  
> 
> >> without losing the previous stored data?
> 
> >>
> 
> >> Here is what i ahve so far:
> 
> >>
> 
> >> ==================================
> 
> >> path = "/home/nikos/public_html/data/files/"
> 
> >>
> 
> >> #read the containing folder and insert new filenames
> 
> >> for result in os.walk(path):
> 
> >
> 
> > You were told yesterday at least twice that os.walk returns a tuple but  
> 
> > you still insist on refusing to take any notice of our replies when it  
> 
> > suits you, preferring instead to waste everbody's time with these  
> 
> > questions.  Or are you trying to get into the Guinness Book of World  
> 
> > Records for the laziest bastard on the planet?
> 
> 
> 
> Hold on a sec ...
> 
> 
> 
> He has
> 
> 
> 
> for result in os.walk(path):
> 
> 	for filename in result[2]:
> 
> 
> 
> So he *did* take notice of that.
> 
> 
> 
> 
> 
> Nikos:
> 
> Expectation is to iterate through a tuple like this:
> 
> 
> 
> for dirpath, dirnames, filenames in os.walk(path):
> 
> 	...

Thank you Michael, yes i ahve understood that myself yesterday after one of the guys here have shown the output of os.walk(path) in IDLE. 
So, yes in fact i was in need for the 3rd item in the tuple, so to get hold on to the files.

Thank you for supporting me, some ppl here think i'am a troll and don't try thinks or ignore evrything but 'some_ppl's_opinion != True'

I'am just sometimes persistant on having thing my way that why i was calling my self Ferrous cRanus, which i changes it since it was annoying....



More information about the Python-list mailing list