Re: [Tutor] odd behavior when renaming a file

2012-05-10 Thread Joel Goldstick
On Thu, May 10, 2012 at 5:05 PM, Prasad, Ramit wrote: >> I have to process a csv file from a business partner.  Oddly (?) they >> don't quote text fields, and the Title field sometimes contains >> commas.  So I wrote some code to count the commas in each line and if >> there were too many, I remov

Re: [Tutor] odd behavior when renaming a file

2012-05-10 Thread Prasad, Ramit
> I have to process a csv file from a business partner. Oddly (?) they > don't quote text fields, and the Title field sometimes contains > commas. So I wrote some code to count the commas in each line and if > there were too many, I removed the extras and wrote the cleaned up > file to the origin

Re: [Tutor] odd behavior when renaming a file

2012-05-10 Thread Alan Gauld
On 10/05/12 21:18, Dave Angel wrote: out_file = open('revelex.csv', 'w') # etc. I would expect the open() to fail... But he's opening it for WRITE, so it gets created just fine. Ah yes, I didn't spot that. :-) Too busy looking for a possible cause of a missing file message...

Re: [Tutor] odd behavior when renaming a file

2012-05-10 Thread Joel Goldstick
On Thu, May 10, 2012 at 4:18 PM, Dave Angel wrote: > On 05/10/2012 12:56 PM, Alan Gauld wrote: >> On 09/05/12 20:26, Joel Goldstick wrote: >>> import os >>> def pre_process(): >>>      if os.path.isfile('revelex.csv'): >>>          os.rename('revelex.csv', 'revelex.tmp') >>>          print "Rename

Re: [Tutor] odd behavior when renaming a file

2012-05-10 Thread Dave Angel
On 05/10/2012 12:56 PM, Alan Gauld wrote: > On 09/05/12 20:26, Joel Goldstick wrote: >> import os >> def pre_process(): >> if os.path.isfile('revelex.csv'): >> os.rename('revelex.csv', 'revelex.tmp') >> print "Renamed ok" >> else: >> print "Exiting, no revelex.c

Re: [Tutor] odd behavior when renaming a file

2012-05-10 Thread Joel Goldstick
On Wed, May 9, 2012 at 5:21 PM, Peter Otten <__pete...@web.de> wrote: > Joel Goldstick wrote: > >> import os >> def pre_process(): >>     if os.path.isfile('revelex.csv'): >>         os.rename('revelex.csv', 'revelex.tmp') >>         print "Renamed ok" >>     else: >>         print "Exiting, no rev

Re: [Tutor] odd behavior when renaming a file

2012-05-10 Thread Alan Gauld
On 09/05/12 20:26, Joel Goldstick wrote: import os def pre_process(): if os.path.isfile('revelex.csv'): os.rename('revelex.csv', 'revelex.tmp') print "Renamed ok" else: print "Exiting, no revelex.csv file available" exit() out_file = open('revele

Re: [Tutor] odd behavior when renaming a file

2012-05-09 Thread Peter Otten
Joel Goldstick wrote: > import os > def pre_process(): > if os.path.isfile('revelex.csv'): > os.rename('revelex.csv', 'revelex.tmp') > print "Renamed ok" > else: > print "Exiting, no revelex.csv file available" > exit() > out_file = open('revelex.csv', '

Re: [Tutor] odd behavior when renaming a file

2012-05-09 Thread Walter Prins
Hi, On 9 May 2012 20:26, Joel Goldstick wrote: > import os > def pre_process(): >if os.path.isfile('revelex.csv'): >os.rename('revelex.csv', 'revelex.tmp') >print "Renamed ok" >else: >print "Exiting, no revelex.csv file available" >exit() >out_file = o

[Tutor] odd behavior when renaming a file

2012-05-09 Thread Joel Goldstick
import os def pre_process(): if os.path.isfile('revelex.csv'): os.rename('revelex.csv', 'revelex.tmp') print "Renamed ok" else: print "Exiting, no revelex.csv file available" exit() out_file = open('revelex.csv', 'w') # etc. if __name__ == '__main__'