Writing files

Adonis Vargas adonis at REMOVETHISearthlink.net
Mon Mar 19 15:20:44 EDT 2007


I am writing a program that walks a directory full of mp3s reads their 
ID3 data (using Mutagen), this part works perfectly. The problem is I 
write these tags to a CSV file through the CSV module. But when I read 
the file the file seems to be incomplete. Further inspecting it has 
seemed to have stopped writing to the file at a certain point. Something 
in my code? a bug?

System: Linux 2.4.31 (Slackware), Python 2.5c1

Any help is greatly appreciated.

Adonis

-- 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()



More information about the Python-list mailing list