Dear all,
I am reaching out to you because I have a small issue I need to deal with, yet I feel that it requires pretty advanced coding to solve. I have a whole lot of .arff files that would simply need a case number added to every line of data. I've been able to do this for 1 file, but now I need to extend the coding to all files (as there are 100+ files). I have pretty much all the coding, except for the last part of the puzzle, being writing the data back to a file that takes the previous file name and simply adds a prefix 'TRE'. This is the code I have so far: import os, glob path = 'blablabla' for infile in glob.glob( os.path.join(path, '*.arff') ): print "current file is: " + infile lines=infile.readlines() infile.close() outtext = ['%d %s' % (i, line) for i, line in enumerate(lines)] outfile = open("TRE_previous file-name.arff","w") outfile.writelines(outtext) outfile.close() Is there anyone who could give me some guidance on where to take it from here? Thanks in advance. Sincerely, Daan
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor