Re: reading variable names and values from a file
- To: mathgroup at smc.vnet.net
- Subject: [mg41546] Re: reading variable names and values from a file
- From: Bill Rowe <listuser at earthlink.net>
- Date: Mon, 26 May 2003 05:46:24 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 5/24/03 at 1:03 AM, cww at lanl.gov (Chuck Wilkerson) wrote: >I would like to read a text file that looks like the following: >a 1 >b 2 >c 3 .... >and end up having assigned the value in the second column to the >variable name in the first column, i.e. >a=1 >b=2 >c=3 .... Try the following: data=ReadList[file, {Word, Number}] Evaluate[ToExpression[First/@data]]=Last/@data