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


Groups > comp.lang.python > #97903

Re: Pandas' loading a CSV file problem

Path csiph.com!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <motoom@xs4all.nl>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'encoded': 0.05; "subject:' ": 0.07; 'subject:file': 0.07; 'utf-8': 0.07; 'csv': 0.09; 'subject:CSV': 0.09; 'assume': 0.11; 'codec': 0.16; 'decode': 0.16; 'encoded.': 0.16; 'from:addr:xs4all.nl': 0.16; 'received:194.109': 0.16; 'received:194.109.24': 0.16; 'received:xs4all.nl': 0.16; 'wrote:': 0.16; 'byte': 0.18; 'windows': 0.20; 'cc:2**0': 0.20; 'subject:problem': 0.22; 'this:': 0.23; 'cc:addr:gmail.com': 0.24; 'header:In-Reply-To:1': 0.24; 'skip:" 20': 0.26; 'skip:( 20': 0.28; 'guess': 0.31; "can't": 0.32; 'file': 0.34; 'skip:p 30': 0.35; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'skip:p 20': 0.38; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'header:Message-Id:1': 0.61; 'greetings,': 0.61; 'received:194': 0.61; 'received:nl': 0.72
Content-Type text/plain; charset=us-ascii
Mime-Version 1.0 (Mac OS X Mail 8.2 \(2104\))
Subject Re: Pandas' loading a CSV file problem
From Michiel Overtoom <motoom@xs4all.nl>
In-Reply-To <CA+ZkTxvHO802k+3WC_E5StvH37vF6qF-=_ibs4kN_NodHz9EYQ@mail.gmail.com>
Date Thu, 22 Oct 2015 15:23:27 +0200
Cc Ek Esawi <esawiek@gmail.com>
Content-Transfer-Encoding quoted-printable
References <CA+ZkTxvHO802k+3WC_E5StvH37vF6qF-=_ibs4kN_NodHz9EYQ@mail.gmail.com>
To Pyton List <python-list@python.org>
X-Mailer Apple Mail (2.2104)
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.101.1445520278.878.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1445520278 news.xs4all.nl 23829 [2001:888:2000:d::a6]:40544
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97903

Show key headers only | View raw


Hi Ek,

> On 22 Oct 2015, at 14:44, Ek Esawi <esawiek@gmail.com> wrote:
> 
> f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp1.csv')
> File "pandas\parser.pyx", line 1382, in pandas.parser._string_box_utf8 (pandas\parser.c:17655)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 8: invalid start byte

I guess you're on Windows and your CSV file is encoded as Windows-1252. Unless you tell Pandas this it'll assume your file is utf-8 encoded.

Try this:

   f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp1.csv', encoding='windows-1252')

Greetings,



Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Pandas' loading a CSV file problem Michiel Overtoom <motoom@xs4all.nl> - 2015-10-22 15:23 +0200

csiph-web