Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'filename': 0.07; 'filenames': 0.07; 'expectation': 0.09; 'inserted': 0.09; 'iterate': 0.09; 'lawrence': 0.09; 'tuple': 0.09; 'stored': 0.10; 'dirnames,': 0.16; 'dirpath,': 0.16; 'losing': 0.16; 'os.walk': 0.16; 'received:your-server.de': 0.16; 'sec': 0.16; 'subject: \n ': 0.16; 'subject:based': 0.16; 'subject:values': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'skip:" 30': 0.20; 'trying': 0.21; 'insert': 0.23; 'this:': 0.23; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '+0100,': 0.29; 'questions.': 0.29; 'that.': 0.30; 'folder': 0.30; 'waste': 0.30; 'subject:data': 0.33; 'to:addr:python-list': 0.33; 'path': 0.35; 'but': 0.36; 'display': 0.36; 'previous': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'files': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'notice': 0.39; 'containing': 0.61; 'world': 0.63; 'skip:= 30': 0.64; 'here': 0.65; 'our': 0.65; 'records': 0.68; '2013': 0.84; 'refusing': 0.84; 'suits': 0.84 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: python-list@python.org Subject: Re: sync databse table based on current directory data without losign previous values References: <390f0dc5-5750-4849-9433-a19d90cc8566@googlegroups.com> Date: Wed, 06 Mar 2013 15:04:26 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "Michael Ross" In-Reply-To: User-Agent: Opera Mail/12.14 (Win32) X-Authenticated-Sender: gmx@ross.cx X-Virus-Scanned: Clear (ClamAV 0.97.6/16791/Wed Mar 6 06:40:00 2013) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 60 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362578676 news.xs4all.nl 6868 [2001:888:2000:d::a6]:35436 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40638 On Wed, 06 Mar 2013 12:52:00 +0100, Mark Lawrence = wrote: > On 06/03/2013 07:45, =CE=9D=CE=AF=CE=BA=CE=BF=CF=82 =CE=93=CE=BA=CF=81= 33=CE=BA 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: >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> path =3D "/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 bu= t = > 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): ...