jaysonit Posted March 10, 2008 Posted March 10, 2008 I have made my program in 4 parts and 3 work great. i for the life of me can not get a text filter to work the way i need to. i am new to autoit. a week or so. this is what i need.file1.txt looks like this:just lines of text and more textblank space. ----- i know how to get rid of blank lines.http://www.what ever.com1blank spacetext text and yet more text http://www.what ever.com2what i need the out come to look lik.file2.txt need to look like this.http://www.what ever.com1http://www.what ever.com2at this time my program will do the rest i have mode it to do.if any one cen help it would make life so easy. i have no code for this part as i have not yet got any idea what to do. thanks for reading and helping if you can.ps: i have looked at every post about text on this forum and none i have seen seam to do what i need.
notta Posted March 10, 2008 Posted March 10, 2008 I have made my program in 4 parts and 3 work great. i for the life of me can not get a text filter to work the way i need to. i am new to autoit. a week or so. this is what i need.file1.txt looks like this:just lines of text and more textblank space. ----- i know how to get rid of blank lines.http://www.what ever.com1blank spacetext text and yet more text http://www.what ever.com2what i need the out come to look lik.file2.txt need to look like this.http://www.what ever.com1http://www.what ever.com2at this time my program will do the rest i have mode it to do.if any one cen help it would make life so easy. i have no code for this part as i have not yet got any idea what to do. thanks for reading and helping if you can.ps: i have looked at every post about text on this forum and none i have seen seam to do what i need. Look at this StringInStr in the autoit manual. Should do what you need.
spudw2k Posted March 10, 2008 Posted March 10, 2008 (edited) You could use StringReplace() or you can Trim the string by using StringInstr to find the char position to trim from. If you have an example I can make some code to "filter" it and explain how. Edited March 10, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
jaysonit Posted March 10, 2008 Author Posted March 10, 2008 You could use StringReplace() or you can Trim the string by using StringInstr to find the char position to trim from. If you have an example I can make some code to "filter" it and explain how.ok the text is the file at start.Website Address: http://MadVlad.comjay Vemma allows you to enjoy business ownership with none of the traditional entrepreneurial risk.No Bosses.No Overhead.No headaches.You don't have any inventory or employee headaches. We want to do everything we can to make you a success,so you can either make Vemma a career for yourself or just enjoy the opportunity to earn a substantial secondary income.One of the best opportunities on the net today,And without doubt the healthiest!Thanks,Amanda Manermaner.amanda@gmail.com ===============================================Got HotLinks? Click below for your credits!http://www.gotsafelist.comYou were sent this email because you are a member of GotSafelist.Com.If you wish to unsubscribe or switch to vacation mode you can do so by going to http://www.gotsafelist.com/login_V2.php and logging in.If this ad is believed to be against our rules please report it here:http://www.gotsafelist.com/complaints_V2.php?id=richmacNo Sat/Cable Box? Digital TV on your PC or Laptop?TV on PC - Instant Download Up & Running in 5 MinutesUp & Running in 5 Minutesi need it to look like this. (i did this by hand)http://MadVlad.comhttp://www.gotsafelist.comhttp://www.gotsafelist.com/complaints_V2.php?id=richmaci dont know if this wll help i am looking aswell so i can lurn but if you can help that would be great.i will post the hole code when dont for others to use nd lurn from.
spudw2k Posted March 11, 2008 Posted March 11, 2008 (edited) Sweet, no prob. Here's what I would do, providing the text files are small in size, like this one. Description of process: 1st. Parse the file one line at a time and copy the entire line if that line contains the string "http://" 2nd. Parse the collected data, trim and filter Actuall process: 1. Ask for text file as input. 2. Read text file to array and loop through array; parse lines that contain "http://" 3. Save parse as temp file 4. Read temp file to array and loop through array; trimming before and after web links and filtering. 5. Delete temp file and save output file. expandcollapse popup#include <File.au3> $textfile = FileOpenDialog("Textfile",@WorkingDir,"Text File (*.txt)") Dim $arrTextFile Dim $output If Not _FileReadToArray($textfile,$arrTextFile) Then MsgBox(4096,"Error", " Error reading text file. error:" & @error) Exit EndIf For $x = 1 to $arrTextFile[0] ;Loop through text file lines and parse for http:// If StringInstr($arrTextFile[$x],"http://") Then $output = $output & $arrTextFile[$x] & @CRLF EndIf Next $arrTextFile = 0 ;Cleanup msgbox(0,"So Far.",$output) ;Debug to show you what I have at this point $tempfile = @WorkingDir & "\temp.txt" FileWrite($tempfile,$output) $output = "" _FileReadToArray($tempfile,$arrTextFile) FileDelete($tempfile) For $x = 1 to $arrTextFile[0] ;Loop through text file lines and trim data before and after web links $start = StringInstr($arrTextFile[$x],"http://") If $start > 1 Then ;Trim ahead of link $arrTextFile[$x] = StringRight($arrTextFile[$x],StringLen($arrTextFile[$x])-$start+1) EndIf $end = StringInstr($arrTextFile[$x]," ") If $end > 0 Then ;Trim behind link $arrTextFile[$x] = StringLeft($arrTextFile[$x],$end - 1) EndIf If StringInstr($arrTextFile[$x],"login_v2") < 1 Then ;Filter for "login_v2" $output = $output & $arrTextFile[$x] & @CRLF EndIf Next $arrTextFile = 0 ;Cleanup msgbox(0,"The Result.",$output) ;Debug to show you what I have at this point Do $file = FileSaveDialog("Save As",@WorkingDir,"Text File (*.txt)") Until $file > "" If StringLeft(StringRight($file,4),1) <> "." Then $file = $file & ".txt" FileWrite($file,$output) Exit Edited March 11, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
weaponx Posted March 11, 2008 Posted March 11, 2008 Dim $infile = "test.txt" Dim $outfile = "out.txt" $data = FileRead($infile) $array = StringRegExp($data, "(http://.+?)\s", 3) $handle = FileOpen($outfile, 1) For $X = 0 to Ubound($array) - 1 FileWriteLine($handle,$array[$X]) ConsoleWrite("[" & $X & "] = " & $array[$X] & @CRLF) Next
jaysonit Posted March 11, 2008 Author Posted March 11, 2008 Thank you all for the help. i have used the input i got from you to do what i needed.
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