Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39348 > unrolled thread

Re: working with csv module in python

Started byDave Angel <davea@davea.name>
First post2013-02-20 06:22 -0500
Last post2013-02-20 06:22 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: working with csv module in python Dave Angel <davea@davea.name> - 2013-02-20 06:22 -0500

#39348 — Re: working with csv module in python

FromDave Angel <davea@davea.name>
Date2013-02-20 06:22 -0500
SubjectRe: working with csv module in python
Message-ID<mailman.2107.1361359386.2939.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web