On Fri, Mar 13, 2009 at 5:18 PM, per freem <perfr...@gmail.com> wrote:

> hi all,
>
> what's the most efficient / preferred python way of parsing tab separated
> data into arrays? for example if i have a file containing two columns one
> corresponding to names the other numbers:
>
> col1    \t     col 2
> joe    \t  12.3
> jane   \t 155.0
>
> i'd like to parse into an array() such that i can do: mydata[:, 0] and
> mydata[:, 1] to easily access all the columns.
>
> right now i can iterate through the file, parse it manually using the
> split('\t') command and construct a list out of it, then convert it to
> arrays. but there must be a better way?
>
> also, my first column is just a name, and so it is variable in length -- is
> there still a way to store it as an array so i can access: mydata[:, 0] to
> get all the names (as a list)?
>
>
Try matplotlib.mlab.csv2rec or numpy.loadtxt

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from: Norman Oklahoma United States.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to