Jump to content


Photo

Help automating a list of terms to find and replace


  • Please log in to reply
6 replies to this topic

#1 ecrhone

ecrhone
  • Members
  • 2 posts

Posted 24 June 2004 - 05:47 PM

:?: 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

#2 Rajat

Rajat
  • Members
  • 1886 posts

Posted 24 June 2004 - 06:30 PM

u need to use read loop

loop, read, inputfile, outputfile
{
stringreplace
stringreplace
stringreplace
...
fileappend
}

#3 ecrhone

ecrhone
  • Members
  • 2 posts

Posted 24 June 2004 - 07:49 PM

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

#4 Rajat

Rajat
  • Members
  • 1886 posts

Posted 24 June 2004 - 08:57 PM

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.

#5 Beastmaster

Beastmaster
  • Members
  • 191 posts

Posted 24 June 2004 - 10:08 PM

Guess what? I've done that today :p

;; 3U TELECOM Inc.,3U,235233,09116,x09116,PRE ;; line content of MyInput.csv

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...]

#6 Guests

  • Guests

Posted 25 June 2004 - 03:41 PM

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

ecrhone

#7 loc alme

loc alme
  • Members
  • 12 posts

Posted 16 June 2013 - 12:47 AM

Guess what? I've done that today tongue.png

;; 3U TELECOM Inc.,3U,235233,09116,x09116,PRE ;; line content of MyInput.csv



Please check AHK's command reference on the commands used above (marked bold)--> [more...]

please help me too