Re: Import specific columns from a tsv-file
- To: mathgroup at smc.vnet.net
- Subject: [mg92202] Re: Import specific columns from a tsv-file
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 23 Sep 2008 07:30:04 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <gb7ocu$nhp$1@smc.vnet.net>
suladna wrote: > I want to import data from a tsv-file to a Table in Mathematica, without the first column of the tsv-file. What should I write to do this? > > Alternatively I can import the whole tsv-file and then drop the first column from my Mathematica-Table.. but I don't know how to do the "drop column" part. In[1]:= imp = Import["file.tsv.txt", "TSV"] Out[1]= {{"line one", "1,1", "1,2", "1,3"}, {"line two", 2.1, 2.2, 2.3}, {"line three", 3.1, 3.2, 3.3}} In[2]:= data = Rest[Transpose@imp] Out[2]= {{"1,1", 2.1, 3.1}, {"1,2", 2.2, 3.2}, {"1,3", 2.3, 3.3}} In[3]:= data = imp[[All, 2 ;;]] Out[3]= {{"1,1", "1,2", "1,3"}, {2.1, 2.2, 2.3}, {3.1, 3.2, 3.3}} (* among many other ways... *) Regards, -- Jean-Marc