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


Groups > comp.lang.python > #43527

Re: CSV to matrix array

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cantorp@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'element': 0.07; 'puts': 0.07; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.11; 'csv': 0.16; 'freitag,': 0.16; 'subject:CSV': 0.16; 'subject:array': 0.16; 'example': 0.22; 'cc:addr:gmail.com': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**1': 0.23; 'header:User-Agent:1': 0.23; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'array': 0.29; 'file:': 0.31; 'skip:c 30': 0.32; 'position.': 0.33; 'could': 0.34; 'received:209.85': 0.35; 'received:google.com': 0.35; 'skip:> 10': 0.36; 'received:209': 0.37; 'from:no real name:2**0': 0.61; 'pick': 0.64; 'dear': 0.65; 'ana': 0.84; '2013': 0.98
X-Received by 10.49.24.134 with SMTP id u6mr1263034qef.24.1365872775610; Sat, 13 Apr 2013 10:06:15 -0700 (PDT)
Newsgroups comp.lang.python
Date Sat, 13 Apr 2013 10:06:15 -0700 (PDT)
In-Reply-To <eed71ec6-589c-4b10-a617-a8f5145642a6@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=77.1.37.77; posting-account=nfPPQQgAAACm02ZG-fcpr8FpTisjCygl
References <2506a155-40b6-4040-bc12-a08ce0d79cd7@googlegroups.com> <mailman.530.1365787506.3114.python-list@python.org> <eed71ec6-589c-4b10-a617-a8f5145642a6@googlegroups.com>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 77.1.37.77
MIME-Version 1.0
Subject Re: CSV to matrix array
From cantorp@gmail.com
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org, Ana Dionísio <anadionisio257@gmail.com>
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>
Message-ID <mailman.558.1365872784.3114.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365872784 news.xs4all.nl 2659 [2001:888:2000:d::a6]:39776
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43527

Show key headers only | View raw


Dear Ana,

your example data could be transformed into a matrix with

>>>import csv
>>>rows = csv.reader(open("your_data_file.csv"), delimiter=" ")
>>>array = [row for row in rows]
>>>array[0][3]
4

HTH
Paolo

Am Freitag, 12. April 2013 19:29:05 UTC+2 schrieb Ana Dionísio:
> That only puts the data in one column, I wanted to separate it. 
> 
> 
> 
> For example:
> 
> data in csv file:
> 
> 
> 
> 1 2 3 4 5
> 
> 7 8 9 10 11
> 
> a b c d e
> 
> 
> 
> I wanted an array where I could pick an element in each position. In the case above if I did print array[0][3] it would pick 4

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


Thread

Re: CSV to matrix array Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-04-12 19:23 +0200
  Re: CSV to matrix array Ana Dionísio <anadionisio257@gmail.com> - 2013-04-12 10:29 -0700
    Re: CSV to matrix array Dave Angel <davea@davea.name> - 2013-04-12 13:46 -0400
    Re: CSV to matrix array Javier Miranda <javier@codecoa.com> - 2013-04-12 17:45 -0500
    Re: CSV to matrix array cantorp@gmail.com - 2013-04-13 10:06 -0700
    Re: CSV to matrix array cantorp@gmail.com - 2013-04-13 10:06 -0700
  Re: CSV to matrix array Ana Dionísio <anadionisio257@gmail.com> - 2013-04-12 10:29 -0700

csiph-web