Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.05; 'skip:o 50': 0.07; '"w")': 0.09; 'read()': 0.09; 'subject:module': 0.09; 'stored': 0.10; 'subject:python': 0.11; 'f.read()': 0.16; 'naming': 0.16; 'wrote:': 0.17; 'skip:g 40': 0.17; 'string,': 0.17; 'skip:" 40': 0.20; 'file.': 0.20; 'trying': 0.21; 'import': 0.21; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(most': 0.27; 'am,': 0.27; 'forgot': 0.27; 'folder': 0.30; 'error': 0.30; 'code': 0.31; 'file': 0.32; 'print': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'open': 0.35; 'but': 0.36; 'subject:with': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'here': 0.65; 'obvious': 0.71; 'received:74.208': 0.71; 'received:74.208.4.194': 0.84 Date: Wed, 20 Feb 2013 06:22:48 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: python-list@python.org Subject: Re: working with csv module in python References: <20130220102601.GD22457@localhost> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Owrwnyu+LA4nK0Ny0A+BbLfOrBdqJWZlxblatsYSqxD Drn3lvQbnc9oJzTDwxJv0/nKL1zyeBjLl2Y20T/VJErLon++m1 MmuVtg953bBIDRBOvjixEDdsnSGwAyayF8Jxr4Zd25xBWyeT/W yLPUSsAJhB+WnK2aVV359Edyit5/s2OiETbEtPtzhHPpqJpLUq Mry4OwWfn6uExowMhnj0TGwSgCj3SLUjoVQJJvqjd2brs8l8fQ FSP6kFioOVnIWJHKy/kTOB+pLdCQEspCySYim0yBBMbg6iaY9d YxyH2Bd4R18Z1G9gnaTcLQhUjzszAL369vJbQaaB2QhpEyDEQ= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361359386 news.xs4all.nl 6943 [2001:888:2000:d::a6]:35436 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39348 On 02/20/2013 06:01 AM, inshu chauhan wrote: > > >> >> 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 : > > 0x01B64F40> > > Traceback (most recent call last): > File "C:\Users\inshu.chauhan\Desktop\Concatfiles.py", line 6, in > 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