phatzilla Posted September 22, 2008 Share Posted September 22, 2008 (edited) Edit: Thanks figured out first problemSecond problem: (Two pronged issue)Is there anyway to add 'extra' data to a txt file.So if i download 10x txt files from a URL, can i have ALL that text saved in ONE txt file?So file #1 downloaded into Text1.TXTfile #2 downloaded and ADDED to text1.txtSo that after i download ALL 10 text files, i will only have 1 text file but with all the text from the 10 files i downloaded.Second issue: i need to search through thousands of lines of text and take 'snippets' of that text and copy it over to a frest txt file.Example:BlahBlahBlahBlahHELLOYadaYadaYadaBlahBlahBlahBlahWorldYadaYadaYadaBlahBlahBlahBlahImYadaYadaYadaBlahBlahBlahBlahPhatzillaYadaYadaYadaSo what im saying is that im trying to copy the following into my new text file"Hello""World""im""Phatzilla"(all as individual lines). I KNOW that BlahBlahBlahBlah Precedes The word I want to copy and that YadaYadaYada Succeeds the word every single time.So how can i write a script that extracts the word(or should i say string) from between blahblahblah and yadayadayada? Theres thousands of these 'words' and i obviously dont know what they are, but i do know that what precedes and succeeds them is always constant. Edited September 22, 2008 by phatzilla Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 22, 2008 Share Posted September 22, 2008 Check out For/Next loops, _IE* functions, and FileRead()/FileWrite(). Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
phatzilla Posted September 22, 2008 Author Share Posted September 22, 2008 Problem edited. Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 22, 2008 Share Posted September 22, 2008 Once again, Look at FileWrite(), I'm pretty sure if you open in mode 2 it appends the data (adds at the end of the file) Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
phatzilla Posted September 22, 2008 Author Share Posted September 22, 2008 hey edited again (last time i promise Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 22, 2008 Share Posted September 22, 2008 Please stop editing your problem posts. Add to them don't redo them. Leave your initial problems intact so that people who search the forum can gain the help as well. As for reading certain things try reading the file contents with FileReadLine() and look at StringInStr(). Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
phatzilla Posted September 22, 2008 Author Share Posted September 22, 2008 (edited) totally over my head. The problem with StringInStr() is that i dont KNOW what the substring is. I know what string precedes and suceeds it. But i dont know WHAT the string is that im looking for. as in i dont know that its "phatzilla" in the first example. The string in question also varies in character length, so i cant use like StringLeft or StringRight Edited September 22, 2008 by phatzilla Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 22, 2008 Moderators Share Posted September 22, 2008 FileWrite("filename.log", "text downloaded" & @CRLF) to append the text to the file already in question. #include <array.au3> Local $a_sre = StringRegExp(FileRead("filename.log"), "(?i)BlahBlahBlahBlah(.+?)YadaYadaYada", 3) _ArrayDisplay($a_sre) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 22, 2008 Share Posted September 22, 2008 (edited) I don't see how. $File = FileOpen("filename",2) $FileOut = FileOpen("output name",10) For $i = 1 To FileCountLines($File) $line = FileReadLine($File,$i) If StringInStr($line,"stuff before") = 1 And StringInStr($line,"stuff after") = 1 Then $lineout = StringReplace(StringReplace($line,"stuf fbefore",""),"stuff after","") FileWrite($FileOut,$lineout) Next This is an example but may work when you replace the proper things and dim the variables I used. Also I'm not sure if the syntax for everything is perfect (I don't have autoit on this comp to check) so it wouldn't hurt to double check things with the helpfile before you run it, it fails, and you complain. Edit: crud Sm0ke_N beat me to it, and his solution will probably work better XD Edited September 22, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
phatzilla Posted September 22, 2008 Author Share Posted September 22, 2008 (edited) Thanks smoke, that helped! I tried your array thing and it worked perfectly, however i only need the data from array #39 through #138. Everything else is useless to me. I'd like to take the strings stored in the aforementioned arrays and append them to a TXT file. How would i go about doing that? Edited September 22, 2008 by phatzilla Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 22, 2008 Share Posted September 22, 2008 (edited) For $i = 39 To 138 FileWrite($output_file,$a_sre[$i]) Next Something like that should work. Also make sure that the output file was oppened with mode 2 to append the text and not overwrite it. Edited September 22, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
phatzilla Posted September 22, 2008 Author Share Posted September 22, 2008 You guys rock, thanks Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 22, 2008 Share Posted September 22, 2008 You're welcome, glad to help. If all of your problems are fixed please put [sOLVED] in your title so people know that you have what you need and others who are searching can see that this has a solution they may be able to use. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] 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