Hello Anton,

I just had the same problem and came up with the following solution:

a = csv2rec(fname) # read a csv file into a
a[a.dtype.names[5]] # access column 6 (index 5) in the file 

As a shorthand you could assign the column names to another field in the
recarray:

a.cols = a.dtype.names
a[a.cols[5]] # access column 6 (index 5) in the file 

Hope this helps, even though it may not be good coding practice. I am a
novice myself...

Best regards,

Thomas



antonv wrote:
> 
> Hi all,
> 
> I have a lot of csv files to process, all of them with the same number of
> columns. The only issue is that each file has a unique column name for the
> fourth column. 
> 
> All the csv2rec examples I found are using the r.column_name format to
> access the data in that column which is of no use for me because of the
> unique names. Is there a way to access that data using the column number?
> I bet this should be something simple but I cannot figure it out...
> 
> Thanks in advance,
> Anton
> 




-- 
View this message in context: 
http://www.nabble.com/csv2rec-column-names-tp21267055p21809832.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to