AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help automating a list of terms to find and replace

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ecrhone



Joined: 24 Jun 2004
Posts: 2

PostPosted: Thu Jun 24, 2004 6:47 pm    Post subject: Help automating a list of terms to find and replace Reply with quote

Question 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
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Jun 24, 2004 7:30 pm    Post subject: Reply with quote

u need to use read loop

loop, read, inputfile, outputfile
{
stringreplace
stringreplace
stringreplace
...
fileappend
}
_________________
Back to top
View user's profile Send private message
ecrhone



Joined: 24 Jun 2004
Posts: 2

PostPosted: Thu Jun 24, 2004 8:49 pm    Post subject: Hmmm Reply with quote

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
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Jun 24, 2004 9:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
Beastmaster



Joined: 15 Apr 2004
Posts: 182

PostPosted: Thu Jun 24, 2004 11:08 pm    Post subject: Reply with quote

Guess what? I've done that today Razz

;; 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
View user's profile Send private message
Guest






PostPosted: Fri Jun 25, 2004 4:41 pm    Post subject: Many Thanks Reply with quote

Very Happy Beastmaster, Rajat, It worked...what a time saver....
Thanks for being so generous with your time and your skills

ecrhone
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group