Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: Import variable and data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32730] Re: Import variable and data
  • From: lalu_bhatt at yahoo.com (Bhuvanesh)
  • Date: Thu, 7 Feb 2002 05:10:34 -0500 (EST)
  • References: <a3qs8q$2c4$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Mark Van De Vyver" <mvdv at bigfoot.com> wrote:

> 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.

Use Evaluate:

Evaluate[ToExpression[inputData[[1]]]] = inputData[[2]]

This way, it will evaluate the left-hand expression before doing the assignment.

--
Bhuvanesh,
Wolfram Research.


  • Prev by Date: Re: style sheets
  • Next by Date: Re: Finding and replacing
  • Previous by thread: Import variable and data
  • Next by thread: Re: Import variable and data