Re: Writing variables in strings (opened from text files)
- To: mathgroup at smc.vnet.net
- Subject: [mg86861] Re: Writing variables in strings (opened from text files)
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Mon, 24 Mar 2008 01:43:30 -0500 (EST)
- References: <fs4rpo$p75$1@smc.vnet.net>
Hi, game = ToString[Table[RandomInteger[{1, 10}], {200}]]; and w = 1500; StringReplace[game, {" 3," -> " " <> ToString[w] <> ",", " 4," -> " " <> ToString[w] <> ",", " 5," -> " " <> ToString[w] <> ",", " 6," -> " " <> ToString[w] <> ","}] ?? Regards Jens 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 >