Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39241
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <insideshoes@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'error:': 0.05; 'mrab': 0.05; 'escape': 0.07; 'skip:o 50': 0.07; 'subject:help': 0.07; '"w")': 0.09; 'backslash': 0.09; 'ioerror:': 0.09; 'literal': 0.09; 'rows': 0.09; 'skip:r 50': 0.09; 'tab': 0.09; 'stored': 0.10; "'/'": 0.16; "(it's": 0.16; '(windows': 0.16; 'backslashes': 0.16; 'csv': 0.16; 'initially,': 0.16; 'literal,': 0.16; 'literals': 0.16; 'recognise': 0.16; 'sequence,': 0.16; 'skip:g 50': 0.16; 'traceback.': 0.16; 'writer': 0.16; 'string': 0.17; 'wrote:': 0.17; 'skip:g 40': 0.17; 'subject:need': 0.17; 'feb': 0.19; 'equivalent': 0.20; 'skip:" 40': 0.20; 'to:name:python- list@python.org': 0.20; 'import': 0.21; 'occurs': 0.22; "skip:' 40": 0.22; 'allows': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'raw': 0.27; 'merge': 0.27; 'message-id:@mail.gmail.com': 0.27; 'character.': 0.29; 'url:mailman': 0.29; 'character': 0.29; 'starts': 0.29; 'skip:& 10': 0.29; 'folder': 0.30; 'mode': 0.30; 'subject: : ': 0.30; 'url:python': 0.32; 'file': 0.32; 'url:listinfo': 0.32; 'says': 0.33; 'traceback': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'equal': 0.33; 'skip:& 20': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'path': 0.35; 'sequence': 0.35; 'pm,': 0.35; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'url:mail': 0.40; "you'll": 0.62; 'here': 0.65; 'programme': 0.69; '2013': 0.84; 'treats': 0.84; 'subject:urgent': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=Pnp1gdJwxD8Yg+wMkxc00OCCpVSdLh+QOnr7ZMFl65U=; b=PsiUmeiyLvjp/REaVR9UjidzXgVFYbG3SFA2UQDKzMYdGy0UzBvRX1hHLGjMbbFgwf zA96ha55z0XIb95a4NnaH1zs4RMMwPLX1dn+sOK0s9qf91VNUguHCQVGNR+MDhRoB4gj RxjeEVKDsnXcoNG2xMCq0fymHDGHGTdw5BrmA7bQ3S3Yvuf4xQfEFgexkKjYpDvxGlMH k3L8ttSOSs1fNE57eRqNtTUIfPZW6IbZXPA1mdhYyt3C67miAVb+61tTxdyx1x2GjJae j37rBaXY0Axj92K07Z+t1DK1/Q/18KVg7w49YeKa0sEDU9nD8e1BR8Mcf+MfZoIJDkMp O0WA== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.33.203 with SMTP id t11mr8585810igi.97.1361289509852; Tue, 19 Feb 2013 07:58:29 -0800 (PST) |
| In-Reply-To | <5123A03F.1000705@mrabarnett.plus.com> |
| References | <CAFqGZREMOm4YSntzwie8o=RmusdV8KzrggY0wK8w4vCXWuwmBw@mail.gmail.com> <5123A03F.1000705@mrabarnett.plus.com> |
| Date | Tue, 19 Feb 2013 16:58:29 +0100 |
| Subject | Re: IOerror : need urgent help |
| From | inshu chauhan <insideshoes@gmail.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=f46d044788dbabd7da04d615e927 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2039.1361289519.2939.python-list@python.org> (permalink) |
| Lines | 143 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361289519 news.xs4all.nl 6961 [2001:888:2000:d::a6]:51653 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39241 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Tue, Feb 19, 2013 at 4:54 PM, MRAB <python@mrabarnett.plus.com> wrote:
> On 2013-02-19 15:27, inshu chauhan wrote:
>
>> Here is my attempt to merge 10 files stored in a folder into a single
>> file :
>>
>> import csv
>>
>> with open("C:\Users\inshu.chauhan\**Desktop\test.arff", "w") as w:
>> writer = csv.writer(w)
>> for f in glob.glob("C:\Users\inshu.**chauhan\Desktop\For
>> Model_600\*.arff"):
>> rows = open(f, "r").readlines()
>> writer.writerows(rows)
>>
>>
>> Error:
>>
>> Traceback (most recent call last):
>> File "C:\Users\inshu.chauhan\**Desktop\Mergefiles.py", line 3, in
>> <module>
>> with open("C:\Users\inshu.chauhan\**Desktop\test.arff", "w") as w:
>> IOError: [Errno 22] invalid mode ('w') or filename:
>> 'C:\\Users\\inshu.chauhan\\**Desktop\test.arff'
>>
>> Why my programme is not working ?? :(
>>
>> Look at the traceback. It says that the path is:
>
> 'C:\\Users\\inshu.chauhan\\**Desktop\test.arff'
>
> All but one of the backslashes are doubled.
>
> That's because the backslash character \ starts an escape sequence, but
> if it can't recognise the escape sequence, it treats the backslash as a
> literal character.
>
> In that string literal, '\t' is an escape sequence representing a tab
> character (it's equal to chr(9)), but '\U', '\i' and '\D' are not
> escape sequences, so they are equivalent to '\\U, '\\i' and '\\D'
> respectively.
>
> What you should do is use raw string literals for paths:
>
>
> r"C:\Users\inshu.chauhan\**Desktop\test.arff"
>
> or use '/' instead (Windows allows it as an alternative, unless it
> occurs initially, which you'll rarely want to do in practice):
>
> "C:/Users/inshu.chauhan/**Desktop/test.arff"
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
Thanks I understood the problem now and my programme is working !!
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: IOerror : need urgent help inshu chauhan <insideshoes@gmail.com> - 2013-02-19 16:58 +0100
csiph-web