Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97042
| Path | csiph.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; 'lines.': 0.07; 'repeated': 0.07; 'encoding.': 0.09; 'format?': 0.09; 'indication': 0.09; 'wed,': 0.15; 'encoding': 0.15; '23,': 0.16; 'adjacent': 0.16; 'file?': 0.16; 'subject:non': 0.16; 'wrote:': 0.16; 'programmer': 0.18; 'all,': 0.20; '2015': 0.20; 'ascii': 0.22; 'sep': 0.22; 'file.': 0.22; 'am,': 0.23; 'header:In-Reply- To:1': 0.24; 'appear': 0.26; 'message-id:@mail.gmail.com': 0.27; '32-bit': 0.29; 'spaces': 0.29; 'guess': 0.31; 'probably': 0.31; 'non': 0.32; 'extract': 0.33; 'items.': 0.33; 'file': 0.34; 'this?': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'text': 0.35; 'but': 0.36; 'there': 0.36; 'lines': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'wrong': 0.38; 'data': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'avoid': 0.61; 'sample': 0.63; 'information': 0.63; 'between': 0.65; 'expert': 0.70; 'to:name:python': 0.84; 'hand,': 0.97 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=q0HOZ5NYEXFb1apJmaCAHfNXRVEBDm0vVBg8Wcy2s9g=; b=QhYEgfM2aHBjIjnjLsM2VIPX5gH8h61HnFXtWiMTfT+3ftIJBYl6vlXcXYvquXilN/ Cwng1jbBY/tHoBk6KJUZkMHS12SpxMIAtgtlP/h7Jwg5FTSHxmgrtIf4/hT1hWDrTUq1 b+jD8odc7++1+blIhJXWtlsnGr+FATGdtd1tQJ/SqtFAm4d22TY1nTjCU1IlZobX20Sc w0FiZHYa8Jr3vd+fomXCs9SAe7Iy06xC35idIDjmcYuoScA06gLZgqPCZBf9q6ucAHvw 4Exuy4F+rJmyALskaTP1U4nllNup5/S7SaR5fGIm5ZKOFPJ1kutdMip3Bt66v3QK+d4A Fo9g== |
| X-Received | by 10.129.45.194 with SMTP id t185mr27588779ywt.111.1443024495677; Wed, 23 Sep 2015 09:08:15 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <CAFHq_S4dQxkQoHhP0hQfNvZ0KVtz2F-PFqbePOyYUGFXCLqipg@mail.gmail.com> |
| References | <CAFHq_S4dQxkQoHhP0hQfNvZ0KVtz2F-PFqbePOyYUGFXCLqipg@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 23 Sep 2015 10:07:36 -0600 |
| Subject | Re: Readlines returns non ASCII character |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.106.1443024499.28679.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1443024499 news.xs4all.nl 23821 [2001:888:2000:d::a6]:35186 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97042 |
Show key headers only | View raw
On Wed, Sep 23, 2015 at 6:47 AM, SANKAR . <shankarphy@gmail.com> wrote: > Hi all, > > I am not a expert programmer but I have to extract information from a large > file. > I used codecs.open(..) with UTF16 encoding to read this file. It could > read all the lines in the file but returns with the non Ascii characters. > Below are 5 sample lines. How do I avoid having this non Ascii items. Is > there a better way to read this? I suspect that what you want is not "non-ASCII" but just to read the file without all the mojibake, which is likely an indication that you're using the wrong encoding. Do you know that UTF-16 is actually the encoding of the file? Based on the spaces that appear between adjacent characters, I would guess that this is probably in a 32-bit encoding, perhaps UTF-32. On the other hand, the repeated 0x00ff 0x00fe 0x00ff are very curious; I don't see how that could be valid UTF-32. Are you sure that this is a text file and not some propietary binary data format?
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Readlines returns non ASCII character Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-23 10:07 -0600
csiph-web