# -*-coding: utf8-*-
# Title: remcol.py
# WARNING: UNTESTED
def remove_column(srcdir, dstdir = None):
if dstdir is None:
dstdir = os.path.join(os.path.expanduser("~"), "columnremoved")
# this guarantees that this function won't overwrite anything on the disk
raise Error(("destination directory exists", dstdir))
for filename in os.listdir(srcdir):
if not filename.endswith(".txt"):
inname = os.path.join(srcdir, filename)
outname = os.path.join(dstdir, filename)
with open(outname, "w") as ofh:
with open(inname, "r") as ifh:
for line in ifh:
line = line.split(",", 1)
if __name__ == "__main__":
dstdir = remove_column(r"/path/to/the/directory/containing/the/3200/files")
print("output files written to directory '%s'" % dstdir)
Man that was awesome.Python is really quick!It processed all this files in about 5 seconds!I am stunned!By the way what books do you suggest so that I can learn python?
Thank you again for this exceptional script.
By the way what books do you suggest so that I can learn python?
I suggest to start with 'dive into python' (or into python 3 if you want to use python 3). Notice that a good part of proficiency in python programming comes from knowing existing libraries (especially the standard library). This can be acquired only by writing many scripts (and reading the python forum).