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


Groups > comp.lang.python > #75347

Re: Load a CSV with different row lengths

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.033
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'output': 0.05; 'inserts': 0.09; 'rows,': 0.09; 'cc:addr:python-list': 0.11; 'csv': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'numpy': 0.16; 'subject:CSV': 0.16; 'unexpected': 0.16; 'sender:addr:gmail.com': 0.17; 'file,': 0.19; 'code,': 0.22; 'python?': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'load': 0.23; 'skip': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header :In-Reply-To:1': 0.27; 'tried': 0.27; 'generally': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'helpful.': 0.31; 'loading': 0.31; 'run': 0.32; 'cases': 0.33; 'subject:with': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; "didn't": 0.36; 'useful': 0.36; 'expected': 0.38; 'feedback': 0.38; 'files': 0.38; "couldn't": 0.39; 'how': 0.40; 'read': 0.60; 'length': 0.61; "you'll": 0.62; 'complete': 0.62; 'provide': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'details': 0.65; 'subject:Load': 0.84; 'response,': 0.91; 'trouble.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=YCaHqF5931PRDFU0amZV6P9aqg8+gntHaQV2Mbnf130=; b=Z1yQkbrcf2HzXcJMq7A1FHVuPNmHxasS2m/0DAHDIomUqGTSl7NCzai8UXC3VaAEtK 4bLVOlHu4LRTZtLdtOzHR/iDlUqmorVTyXEH+9ZLUV0ltflMUFr1tKasyXXHs4bkqjpo MxbSO3BE5hUbSQ91vayJoehJ8/F/hJvARt5aYLIYP/W/bRwvvYMkdNVeBVnGTIpYCPUt VEddRnaaPpwoRV+5QzCToiTHsYlRN/fxcajjB9OLwR/LJxfkCglrt+VwqDcQi8XVKT83 /XZdAfsPh4IYNH60y6I7r6gD1fH9DBCcmuyCnzeuhDT7OJVytoZGyORFazQ1HaiJTmX8 5mgA==
MIME-Version 1.0
X-Received by 10.50.33.100 with SMTP id q4mr5287936igi.8.1406629754215; Tue, 29 Jul 2014 03:29:14 -0700 (PDT)
Sender skip.montanaro@gmail.com
In-Reply-To <CAKcMNB+pYdcETcCs=QEPhU-mLr3nwqX0T66_jT1zq-vgWGMeLg@mail.gmail.com>
References <CAKcMNB+pYdcETcCs=QEPhU-mLr3nwqX0T66_jT1zq-vgWGMeLg@mail.gmail.com>
Date Tue, 29 Jul 2014 05:29:14 -0500
X-Google-Sender-Auth ES9Q18-ap0qH46ndljdSe0i1GK8
Subject Re: Load a CSV with different row lengths
From Skip Montanaro <skip@pobox.com>
To Ryan de Vera <ryan.devera.03@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc Python <python-list@python.org>
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 <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.12414.1406629762.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406629762 news.xs4all.nl 2964 [2001:888:2000:d::a6]:34087
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75347

Show key headers only | View raw


> How can I load this into python? I tried using both NumPy and Pandas.

To add to Peter's response, I would be very surprised if numpy or
Pandas couldn't be coaxed into loading your CSV file, but you didn't
provide any details about what you expected and what you got. I've
used Pandas to read CSV files a lot recently, and run into any
trouble. (I suspect all but a few have equal length rows, but in cases
where data are missing, I've found it generally inserts NaNs.)

In general, you'll get more useful feedback with more complete
questions. I'm not saying you need to necessarily provide code, but a
traceback or unexpected output would be helpful.

Skip

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


Thread

Re: Load a CSV with different row lengths Skip Montanaro <skip@pobox.com> - 2014-07-29 05:29 -0500

csiph-web