working with csv module in python
Dave Angel
davea at davea.name
Wed Feb 20 06:22:48 EST 2013
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
More information about the Python-list
mailing list