Writing files

Adonis Vargas adonis at REMOVETHISearthlink.net
Mon Mar 19 20:42:01 CET 2007


kyosohma at gmail.com wrote:
<snip>
>>
>> -- code --
>>
>>      def _scan(self):
>>          outFile = file("mp3.dat", "wb")
>>          outCSV = csv.writer(outFile)
>>          output = list()
>>          for root, dirs, files in os.walk(self.directory):
>>              files = [x for x in files if x.endswith(".mp3")]
>>              for aFile in sorted(files):
>>                  mp3Data = MP3(os.path.join(root, aFile))
>>                  title = mp3Data.get("TIT2")
>>                  output.append([root, aFile, title])
>>              outCSV.writerows(output)
>>              output = list()
> 
> Are you closing the file before you try to read it? Other than that,
> I'm drawing a blank with just this sample to work with. Maybe someone
> else will know...or you could post more code?
> 
> Mike
> 


Actually, I re-ran this in a terminal and it worked perfectly. I was 
using IDLE to write this code, kinda peculiar. Maybe something to do 
with IDLE and CSV (or writing to files) with lines > ~1000. A socket 
timing out maybe?

Thanks anyways.

Adonis



More information about the Python-list mailing list