 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ecrhone
Joined: 24 Jun 2004 Posts: 2
|
Posted: Thu Jun 24, 2004 6:47 pm Post subject: Help automating a list of terms to find and replace |
|
|
I have a list of terms that I would like changed within a large text file. How do I use AutoHotKey to automate these changes? I have tried to use StringReplace but I'm not sure how to loop through the file while using this fuction. Any help is much appreciated.
Thanks |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Thu Jun 24, 2004 7:30 pm Post subject: |
|
|
u need to use read loop
loop, read, inputfile, outputfile
{
stringreplace
stringreplace
stringreplace
...
fileappend
} _________________
 |
|
| Back to top |
|
 |
ecrhone
Joined: 24 Jun 2004 Posts: 2
|
Posted: Thu Jun 24, 2004 8:49 pm Post subject: Hmmm |
|
|
I appreciate your assistance. I've tried your sugesstion to the best of my ability but I've had no success. Here is my a more detailed descrition of my problem. I have a large text document that contains some unwanted free flowing text and some structured text. I'm trying to cleanup the file so that I can import it into MS access.
At the end of hte script you suggested using FileAppend.
Am I correct in assuming I should you the OutPutVar from the StringReplace function?
Thanks |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Thu Jun 24, 2004 9:57 pm Post subject: |
|
|
yes, the StringReplaced outputvar has to be fileappended to the new file. this loop will process one line at a time for whole file and create a new file with replaced text. _________________
 |
|
| Back to top |
|
 |
Beastmaster
Joined: 15 Apr 2004 Posts: 182
|
Posted: Thu Jun 24, 2004 11:08 pm Post subject: |
|
|
Guess what? I've done that today
;; 3U TELECOM Inc.,3U,235233,09116,x09116,PRE ;; line content of MyInput.csv
| Quote: | Loop, read, MyInput.csv, TheOutput.ini
{
StringSplit, Field, A_LoopReadLine, `,
IfInString, Field5, x
Field5 = %Field4%
IfInString, Field6, PRE
StringReplace, Field6, Field6, PRE, Preselection
IfInString, Field6, CBC
StringReplace, Field6, Field6, CBC, Call By Call
FileAppend, [%Field5%]`n`n`tCUSTNAME`t=%A_Space%%Field2%`n`tID`t`t=%A_Space%%Field3%`n`tTARIF`t=%A_Space%`n`tPRODTYPE=%A_Space%%Field6%`n`n
} |
Please check AHK's command reference on the commands used above (marked bold) --> [more...] |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Jun 25, 2004 4:41 pm Post subject: Many Thanks |
|
|
Beastmaster, Rajat, It worked...what a time saver....
Thanks for being so generous with your time and your skills
ecrhone |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|