Re: Extract columns based on their the title in header
- To: mathgroup at smc.vnet.net
- Subject: [mg131691] Re: Extract columns based on their the title in header
- From: Joug Raw <jougraw at gmail.com>
- Date: Sat, 21 Sep 2013 04:37:10 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <20130920110717.97AEE6A3D@smc.vnet.net>
>>but the names of the columns have kind of order The order here means a hint of the content, like height, color, size, taste, age ... I know what I am looking for and can roughly guess the name of the columns that stored the information I want. It is NOT the sequence order or something like that. The columns are completely disordered in the sense of sequence. Sorry for the misleading. On Fri, Sep 20, 2013 at 6:08 PM, Joug Raw <jougraw at gmail.com> wrote: > >>datalist[[All,{1,3}]] > > >>-- > >>Itai Seggev > >>Mathematica Algorithms R&D > > What I want is not to use the number, but the string of the column name. > Because, in reality my table would be super long with thousands of columns. > It is hard for me to know which information stored in which columns, but > the names of the columns have kind of order that allows me to guess. That > is why I need to start from the name string. > > > > On Fri, Sep 20, 2013 at 5:26 PM, Itai Seggev <itais at wolfram.com> wrote: > >> On Fri, Sep 20, 2013 at 07:07:17AM -0400, Joug Raw wrote: >> > >> > I import a CSV file like this: >> > >> > Name, Sex, Age, ... , ... >> > Tom, M, 12, ... ,... >> > Bob, M, 13, >> > Lily, F, 11, >> > Jack, M, 14, >> > Micheal, M, 10, >> > .. >> > >> > It become a list and I call it datalist. Then I want only extract the >> Name >> > and Age for each child in the list. I did some thing like: >> > >> > ColumPos = >> > Map[#[[2]] &, >> > Map[Position[datalist, #] &, {"Name", >> > "Age"}], {2}] >> > Map[Extract[#, ColumPos] &, datalist] >> > >> > Yes, it works. But the code are bit complicated. Any one has any idea to >> > get it done in a more efficient way? >> >> >> datalist[[All,{1,3}]] >> >> -- >> Itai Seggev >> Mathematica Algorithms R&D >> 217-398-0700 >> > >
- References:
- Extract columns based on their the title in header
- From: Joug Raw <jougraw@gmail.com>
- Extract columns based on their the title in header