Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Writing variables in strings (opened from text files)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86872] Re: [mg86847] Writing variables in strings (opened from text files)
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 24 Mar 2008 01:45:38 -0500 (EST)
  • Reply-to: hanlonr at cox.net

To use the value of the variable w rather than the character w use

game1 = StringReplace[game,  " 3," :> (" " <> ToString[w] <> ",")];

Check your use of the variable names gametheory and gametheory1 versus the variable names game and game1


Bob Hanlon

---- "sebastian.cohen at gmail.com" <sebastian.cohen at gmail.com> wrote: 
> Hello everyone,
> 
> Can someone please help me with the following issue? I am importing a
> text file that I want to manipulate (replace some parts) and these
> parts shall be variables. Please help. I tried putting more commas for
> the variable but it didn't worked. I also tried with the ToString
> command with no luck. Thanks for any help !!
> 
> Here is a sample of what I want to do:
> 
> game = Import["c:\textfile.txt", "Text"];
> 
> w = 1500;
> 
> game1 = StringReplace[gametheory, (" 3,") :> (" w,")];
> game1 = StringReplace[gametheory1, (" 4,") :> (" w,")];
> game1 = StringReplace[gametheory1, (" 5,") :> (" w,")];
> game1 = StringReplace[gametheory1, (" 6,") :> (" w,")];
> 
> Export["c:\textfile.txt", game1, "Text"];
> 
> Thanks,
> 
> Sebastian Cohen
> 



  • Prev by Date: Re: Converting 3D graphics to 2D polygons
  • Next by Date: Re: Funny behaviour of ClipboardNotebook[] (Q: How to copy programmatically?)
  • Previous by thread: Re: Writing variables in strings (opened from text files)
  • Next by thread: 3D import/export format problems/bugs