Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43527
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-04-13 10:06 -0700 |
| References | <2506a155-40b6-4040-bc12-a08ce0d79cd7@googlegroups.com> <mailman.530.1365787506.3114.python-list@python.org> <eed71ec6-589c-4b10-a617-a8f5145642a6@googlegroups.com> |
| Subject | Re: CSV to matrix array |
| From | cantorp@gmail.com |
| Message-ID | <mailman.558.1365872784.3114.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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