DEVVED Posted January 24, 2007 Share Posted January 24, 2007 What could I use to extract specific text from a text file? I tried looking through the 'string' and 'file' commands in the AutoIt help file. Link to comment Share on other sites More sharing options...
Immensee Posted January 24, 2007 Share Posted January 24, 2007 hmmm, so u want to get a specific text from a file alright $Handle = FileOpen("YOURFILE.TXT", 0) $string = FileRead($Handle) $yourstring = "MYSTRINGTOSEARCH" $SString = StringInStr($string, $yourstring, 0) $NewString = StringMid($string, $SString, StringLen($yourstring)) If $NewString = $yourstring Then MsgBox(0, "Program Response", "The String you searched for, has been founded! result: " & $NewString) EndIf Exit done -me Link to comment Share on other sites More sharing options...
herewasplato Posted January 24, 2007 Share Posted January 24, 2007 (edited) What could I use to extract specific text from a text file? I tried looking through the 'string' and 'file' commands in the AutoIt help file.Well, you would use the 'file' and 'string' functions... :-)Take a look at the sample script at the bottom of the page for FileRead, then look at StringInStr.Post an example of the code that you have tried.Edit: too late :-) Edited January 24, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Uten Posted January 24, 2007 Share Posted January 24, 2007 @DEVVED. This is a really greate time for you to post some code to show that you take your own questions seriously. Especially since you have asked questions alonge the same line before. Post some code and I'm sure you will get help and pointers to get it right. Start with somthing like Local $filename="c:\mydatafile.txt" Local $data $data = FileRead($filename) ; TODO: Fill in the gaps Happy Scripting. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
DEVVED Posted January 25, 2007 Author Share Posted January 25, 2007 I am very sorry if I am upsetting anybody on the very first forum I have ever joined. It's just that I work with alot of text files and looking for peoples different points of view on working with them. The first 3 posts I made were for a program I just finished thank's to the excellent response and experience from all of you. The last post (this one) is for another program that I am trying to put together that takes a group of text files and extracts specific string out of each one and displays it in another created text file or in a text box in a GUI so if there is a broken pattern you would see it instead of opening the original text files one by one. Again I am sorry and will limit my postings. Link to comment Share on other sites More sharing options...
Psibernetic Posted January 25, 2007 Share Posted January 25, 2007 I dont think that is what he meant, my impression on this forum is if u need help..Ask away!! just we all really like to have source code to look off of for reference, it makes our part of helping you 100x easier, and makes it alot easier for you considering sometimes we will actually give you a post of the corrected source you posted... [sup]Psibernetic[/sup]My Creations:X-HideSecuracy Link to comment Share on other sites More sharing options...
herewasplato Posted January 25, 2007 Share Posted January 25, 2007 ...The last post (this one) is for another program that I am trying to put together that takes a group of text files and extracts specific string out of each one and displays it in...Asking you to post some code also helps us understand what you are wanting to do. "Extract text" can means a few different things... with your further explanation above, I can now eliminate some of the meanings and ask...:Is the text string of interest always in the same location in these files?i.e. it might always be on line 12, starting at column position 5.Or, is the text string of interest in various places in each file? ...but hopefully is preceded by some text to key off of.Does the text string of interest only appear once in one file? If multiple times, do you want to locate (extract) all occurrences?How large are these text files? ...a few KB or several GB?We would need to know a bit more about the info to be displayed before suggesting a method of display. Do you want a human to find any anomaly or the script? If the script, then perhaps you would only want to display the info from the last 2 or 3 files checked and have the script halt upon finding an anomaly.hope this helps. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Uten Posted January 26, 2007 Share Posted January 26, 2007 I am very sorry if I am upsetting anybody on the very first forum I have ever joined. ..... Again I am sorry and will limit my postings.No one is upset. My point is you have to give to get. So if you give by, providing some code (we all learn form reading other peoples code), you will get code samples and opinions on how to solve your tasks. So if you want peoples view on working with text files. Describe your task. Add some code solving the task and ask if there is a better way to achieve your goal.So finally, don't limit your posting! just follow some simple guidelines and you will give and get from the forum. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling 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