On 02/20/2013 06:01 AM, inshu chauhan wrote:
<snip>
For simple concating the files , I tried the following code :
import glob
with open(r"C:\Users\inshu.chauhan\Desktop\test2.arff", "w") as w:
print w
for f in glob.glob(r"C:\Users\inshu.chauhan\Desktop\For
Model_600\*.arff"):
You forgot to open file f. f is a string, naming a single file.
g = f.read()
w.write(g)
But I think I am having an obvious error :
<open file 'C:\Users\inshu.chauhan\Desktop\test2.arff', mode 'w' at
0x01B64F40>
Traceback (most recent call last):
File "C:\Users\inshu.chauhan\Desktop\Concatfiles.py", line 6, in <module>
g = f.read()
AttributeError: 'str' object has no attribute 'read'
Here I am trying to refer the files stored in my folder by 'f', Why read()
is not working ?
--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list