Keep the flattened data array others suggested, and then just split it like
this: *(replace `example_data`, `_array`, and `columns`)*

>>> example_data = range(15)

>>> split_array = lambda _array, colums: \

. . .        [_array[i:i + colums] for i in \

. . .                xrange(0, len(_array), colums)]

 >>> print split_array(example_data, 5)

[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]

Gist <https://gist.github.com/anonymous/f9064e4c8790ae037ec6>

What do you guys think?


On Fri, Apr 12, 2013 at 12:46 PM, Dave Angel <da...@davea.name> wrote:

> On 04/12/2013 01:29 PM, Ana Dionísio wrote:
>
>> 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
>>
>>
> I know nothing about numpy.
>
> How about something like:
>     import csv
>     myreader = csv.reader(....)
>     mylist = list(myreader)
>
>
> Presumably you can fill in the details.  Anyway, I think this will give
> you a list of lists, and perhaps you can convert that to a numpy array, if
> you really need one of those.
>
>
> --
> DaveA
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>



-- 
Javier Miranda
Mobile: +52 333 129 20 70
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to