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


Groups > comp.lang.python > #43472

Re: CSV to matrix array

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=8075e7a16=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.095
X-Spam-Evidence '*H*': 0.81; '*S*': 0.00; 'rows': 0.09; 'cc:addr :python-list': 0.11; 'columns': 0.16; 'csv': 0.16; 'loops': 0.16; 'numpy': 0.16; 'subject:CSV': 0.16; 'subject:array': 0.16; 'input': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'file.': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'array': 0.29; 'file': 0.32; 'me?': 0.32; 'thanks!': 0.32; '-----': 0.33; 'created': 0.35; 'but': 0.35; 'skip:o 20': 0.38; 'thank': 0.38; 'how': 0.40; 'you.': 0.62; 'information': 0.63; 'received:194': 0.64; 'to:addr:gmail.com': 0.65; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'matrix.': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.87,464,1363129200"; d="scan'208";a="1368955"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Fri, 12 Apr 2013 19:23:56 +0200 (CEST)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Ana Dionísio <anadionisio257@gmail.com>
In-Reply-To <2506a155-40b6-4040-bc12-a08ce0d79cd7@googlegroups.com>
Subject Re: CSV to matrix array
MIME-Version 1.0
X-Mailer Zimbra 7.2.2_GA_2852 (ZimbraWebClient - GC7 (Linux)/7.2.2_GA_2852)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc 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 <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.530.1365787506.3114.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365787506 news.xs4all.nl 2652 [2001:888:2000:d::a6]:53176
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43472

Show key headers only | View raw


----- Original Message -----
> Hello!
> 
> I have a CSV file with 20 rows and 12 columns and I need to store it
> as a matrix. I already created an array with zeros, but I don't know
> how to fill it with the data from the csv file. I have this script:
> 
> import numpy
> from numpy import array
> from array import *
> import csv
> 
> input = open('Cenarios.csv','r')
> cenario = csv.reader(input)
> 
> array=numpy.zeros([20, 12])
> 
> 
> I know I have to use for loops but I don't know how to use it to put
> the data the way I want. Can you help me?
> 
> Thanks!

did you try 

array = numpy.array(list(cenario))

?

JM



-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Back to comp.lang.python | Previous | NextNext 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