MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Import variable and data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32740] Re: Import variable and data
  • From: bghiggins at ucdavis.edu (Brian Higgins)
  • Date: Thu, 7 Feb 2002 05:12:22 -0500 (EST)
  • References: <a3qr9f$29m$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mark, You could try MapThread:

In[1]:=data = {{a, b, c, d}, {1, 23, 45, 678}}

Out[1]={{a, b, c, d}, {1, 23, 45, 678}}

In[3]:=MapThread[Set, data]

Out[3]={1, 23, 45, 678}

In[7]:={a, b,c,d}

Out[7]={1, 23,45,678}

Cheers,

Brian


"Mark Van De Vyver" <mvdv at bigfoot.com> wrote in message news:<a3qr9f$29m$1 at smc.vnet.net>...
> Hi MathGroup,
> 
> I'm having trouble with the following variable and data import:
> The import file is input.txt:
> 
> a b c d
> 1 23 45 678
> 
> inputData=Import[input.txt,"Table"]
> {{a,b,c,d},{1,23,45,678}}
> 
> This all works OK.
> Head[..]  indicates the a,b,c and d are strings, which is fine, because
> ToExpression[..] changes them to symbols.  What I'd like to do is use
> inputData to do the following:
> 
> {a,b,c,d}={1,23,45,678}
> 
> However, if I try
> 
> ToExpression[ inputData[[1]] ] = inputData[[2]]
> 
> I get an error:
> 
> Set::write: Tag ToExpression in ToExpression[a] is Protected.
> 
> If I then enter 'a' in Mathematica I do not get 1 returned!  No matter how I try I
> can't work it so that when I enter the symbol 'a' in Mathematica I get the value
> from inputData[[2]].
> 
> Not sure if that makes sense?


  • Prev by Date: Re: Docs for ml32i1.dll
  • Next by Date: Re: The prime factors of n.
  • Previous by thread: Re: Import variable and data
  • Next by thread: Re: Import variable and data