[SciPy-user] Save column & row headers to csvfile withsomethinglike savetxt?

Dharhas Pothina Dharhas.Pothina at twdb.state.tx.us
Mon Dec 22 14:39:16 EST 2008


thanks. I can live withe the extra 'rows'. I'll try this out tomorrow.

- dharhas

>>> Pierre GM <pgmdevlist at gmail.com> 12/22/08 11:57 AM >>>

dtype = [('rows','|S3')] + [(head, float) for head in headers]
result = np.array([tuple([rowname]+row.tolist())
                    for (rowname,row) in zip(rows, table)], dtype=dtype)

Sorry, looks like you gonna be stuck w/ an extra 'rows' entry in your  
header.


On Dec 22, 2008, at 12:36 PM, Dharhas Pothina wrote:

> Pierre,
>
> Here is an example table :
>
> import numpy as np
> table = np.array([[2.53,3.95,2.79,3.16,2.70], 
> [0.66,0.64,0.35,0.97,0.24],[0.71,0.68,0.37,0.85,0.18]])
> headers =  
> ["2003_C142","JulSep03_CS142","AS03_C142","AS03_C284","AS03_LDY142"]
> rows = "SL","WL","CS"
>
>
> What I would like to output is something along the lines of
> ,2003_C142, JulSep03_CS142, AS03_C142, AS03_C284 ,AS03_LDY142
> SL ,2.53,3.95,2.79,3.16,2.70
> WL ,0.66,0.64,0.35,0.97,0.24
> CS ,0.71,0.68,0.37,0.85,0.18
>
> - dharhas
>
>
>>>> Pierre GM <pgmdevlist at gmail.com> 12/22/08 11:04 AM >>>
>
> On Dec 22, 2008, at 11:59 AM, Dharhas Pothina wrote:
>
>> Will you be working on savetxt or rec2csv?
>
> Both, following the path of genloadtxt.
>
>
>> If rec2csv, do you have alink to any documentation on how to use
>> records in matplotlib. I had a look at the rec2txt and rec2csv links
>> in the documentation but am still not entirely sure how I would
>> convert my table to records and then save them.
>>
>
> Mmh, no doc in mind at the moment. For the conversion of your table to
> a flexible array and back, that depends on your table. Send a simple
> example and I'll see what I can do.
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-user mailing list
SciPy-user at scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user




More information about the SciPy-User mailing list