Hi,
I'm looking to append several text files in one director and out put the combined files into another director. I'm new to Python and just can't get itto work. So far I've been able to create a file in the desired directory but it isn't pulling any of the data in the originating directory. Could please look at my code and tell me what I'm doing wrong.
import os,shutil
f=open("c:\\out put\\testing1.t xt","a+")
for r,d,fi in os.walk("c:\\te st"):
for files in fi:
if files.endswith( ".txt"):
g=open(os.path. join(r+,files))
shutil.copyfile obj(g,f)
g.close()
f.close()
Any help would be great.
Thanks,
Craig Dalton
Business Applications Systems Analyst
Sentara Healthcare Systems
Information Technology
cxdalton@sentar a.com
I'm looking to append several text files in one director and out put the combined files into another director. I'm new to Python and just can't get itto work. So far I've been able to create a file in the desired directory but it isn't pulling any of the data in the originating directory. Could please look at my code and tell me what I'm doing wrong.
import os,shutil
f=open("c:\\out put\\testing1.t xt","a+")
for r,d,fi in os.walk("c:\\te st"):
for files in fi:
if files.endswith( ".txt"):
g=open(os.path. join(r+,files))
shutil.copyfile obj(g,f)
g.close()
f.close()
Any help would be great.
Thanks,
Craig Dalton
Business Applications Systems Analyst
Sentara Healthcare Systems
Information Technology
cxdalton@sentar a.com
Comment