GreYFoX Posted December 27, 2007 Share Posted December 27, 2007 Search for string in a big file (200MB) and replacing it i'm searching for a string inside a file and trying to replace it but i can't seem to find a way to put it in code pls help Link to comment Share on other sites More sharing options...
JustinReno Posted December 27, 2007 Share Posted December 27, 2007 Look in the helpfile. StringReplace() Link to comment Share on other sites More sharing options...
GreYFoX Posted December 27, 2007 Author Share Posted December 27, 2007 (edited) Look in the helpfile. StringReplace()StringReplace ( "string", "searchstring" or start, "replacestring" [, count [, casesense]] ) and how does that help me to search inside the file say "ddddd.dat" ?? (200+MB) Edited December 27, 2007 by GreYFoX Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 27, 2007 Share Posted December 27, 2007 (edited) StringReplace ( "string", "searchstring" or start, "replacestring" [, count [, casesense]] ) and how does that help me to search inside the file say "ddddd.dat" ?? (200+MB) Read the entire file into a single string, then do StringReplace() or StringRegExpReplace(), then write the string back to a file. P.S. The File.au3 UDF has the _ReplaceStringInFile() function just for this. Edited December 27, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GEOSoft Posted December 27, 2007 Share Posted December 27, 2007 StringReplace ( "string", "searchstring" or start, "replacestring" [, count [, casesense]] ) and how does that help me to search inside the file say "ddddd.dat" ?? (200+MB)$oString = StringReplace (FileRead("ddddd.dat")"searchstring", "replacestring") $oFile = FileOpen("ddddd.dat", 2) FileWrite($oFile, $oString) FileClose($oFile) Not tested George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
nobbe Posted December 27, 2007 Share Posted December 27, 2007 hi i assume the file itself is ascii code then read the file line by line, and try to find the string- if you do: replace, write the lines ( replaced or not ) to outfile.. greets nobbe Link to comment Share on other sites More sharing options...
randallc Posted December 27, 2007 Share Posted December 27, 2007 Hi, Whatever you do, this wll be slow unless it is at the end of the file; then you can fast read just the last 100 lines (or whatever), using "_APITailRW" in my signature; and replace fast too. The APIwrite/replace will work fast anywhere in file if you make it the same length as the line its replacing (ie set appropriate parameter in the UDF) Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
GreYFoX Posted December 27, 2007 Author Share Posted December 27, 2007 $oString = StringReplace (FileRead("ddddd.dat")"searchstring", "replacestring") $oFile = FileOpen("ddddd.dat", 2) FileWrite($oFile, $oString) FileClose($oFile) Not testedi mentioned the size of the file..... cause if u do that m8 u'll burn ur processor lol joke Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now