Re: [Tutor] csv manipulation

2008-10-31 Thread Serdar Tumgoren
Hey everyone, I spent a day trying to adapt Mr. Gailer's simple and elegant code to the csv version suggested by Mr. Johnson, but I can't seem to get it working. I adapted the example to my particular use case, but the problem occurs regardless of the dataset used: Namely, when I loop through

Re: [Tutor] csv manipulation

2008-10-31 Thread Serdar Tumgoren
sorry -- forgot to complete my thought in 2nd graf. see below... On Fri, Oct 31, 2008 at 9:29 AM, Serdar Tumgoren [EMAIL PROTECTED]wrote: Hey everyone, I spent a day trying to adapt Mr. Gailer's simple and elegant code to the csv version suggested by Mr. Johnson, but I can't seem to get it

Re: [Tutor] csv manipulation

2008-10-31 Thread Kent Johnson
On Fri, Oct 31, 2008 at 9:32 AM, Serdar Tumgoren [EMAIL PROTECTED] wrote: Below is my code. Can someone tell me how I'm botching the use of the writerows method? Also, on a separate note, is it possible and necessary to close the input and output files when using csv module? I keep getting a

Re: [Tutor] csv manipulation

2008-10-31 Thread Serdar Tumgoren
Aha! That did the trick. Thanks so much! On Fri, Oct 31, 2008 at 10:02 AM, Kent Johnson [EMAIL PROTECTED] wrote: On Fri, Oct 31, 2008 at 9:32 AM, Serdar Tumgoren [EMAIL PROTECTED] wrote: Below is my code. Can someone tell me how I'm botching the use of the writerows method? Also, on a

[Tutor] csv manipulation

2008-10-29 Thread [EMAIL PROTECTED]
hello, i have the follwoing csv file: Berat,Berat,Kuçovë,Skrapar Dibër,Bulqizë,Dibër,Mat Durrës,Durrës,Krujë Elbasan,Elbasan,Gramsh,Librazhd,Peqin Fier,Fier,Lushnjë,Mallakastër Gjirokastër,Gjirokastër,Përmet,Tepelenë Korçë,Devoll,Kolonjë,Korçë,Pogradec Kukës,Has,Kukës,Tropojë

Re: [Tutor] csv manipulation

2008-10-29 Thread A.T.Hofkamp
[EMAIL PROTECTED] wrote: hello, i have the follwoing csv file: Berat,Berat,Kuçovë,Skrapar Dibër,Bulqizë,Dibër,Mat Durrës,Durrës,Krujë Elbasan,Elbasan,Gramsh,Librazhd,Peqin Fier,Fier,Lushnjë,Mallakastër Gjirokastër,Gjirokastër,Përmet,Tepelenë Korçë,Devoll,Kolonjë,Korçë,Pogradec

Re: [Tutor] csv manipulation

2008-10-29 Thread bob gailer
[EMAIL PROTECTED] wrote: hello, i have the follwoing csv file: Berat,Berat,Kuçovë,Skrapar Dibër,Bulqizë,Dibër,Mat Durrës,Durrës,Krujë Elbasan,Elbasan,Gramsh,Librazhd,Peqin Fier,Fier,Lushnjë,Mallakastër Gjirokastër,Gjirokastër,Përmet,Tepelenë Korçë,Devoll,Kolonjë,Korçë,Pogradec

Re: [Tutor] csv manipulation OOPS

2008-10-29 Thread bob gailer
I goofed - overrode input. So I changed my filenames [snip] inputFile = open(path-to-the-input-file, 'r') outputFile = open(path-to-the-output-file, 'w') for line in inputFile : line = line.split(,) # [Berat, Berat, Kuçovë, Skrapar] region = line [0] for district in line[1:]: outputFile

Re: [Tutor] csv manipulation

2008-10-29 Thread Kent Johnson
On Wed, Oct 29, 2008 at 11:28 AM, bob gailer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: hello, i have the follwoing csv file: Berat,Berat,Kuçovë,Skrapar There is a csv module, but for something this simple the following will suffice: as long as none of the data fields include a