Sign in to follow this  
Followers 0
jaysonit

Text file help

7 posts in this topic

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 text

blank space. ----- i know how to get rid of blank lines.

http://www.what ever.com1

blank space

text text and yet more text http://www.what ever.com2

what i need the out come to look lik.

file2.txt need to look like this.

http://www.what ever.com1

http://www.what ever.com2

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

Share this post


Link to post
Share on other sites



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 text

blank space. ----- i know how to get rid of blank lines.

http://www.what ever.com1

blank space

text text and yet more text http://www.what ever.com2

what i need the out come to look lik.

file2.txt need to look like this.

http://www.what ever.com1

http://www.what ever.com2

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by spudw2k

Share this post


Link to post
Share on other sites

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

jay

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 Maner

maner.amanda@gmail.com

===============================================

Got HotLinks? Click below for your credits!

http://www.gotsafelist.com

You 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=richmac

No Sat/Cable Box? Digital TV on your PC or Laptop?

TV on PC - Instant Download Up & Running in 5 Minutes

Up & Running in 5 Minutes

i need it to look like this. (i did this by hand)

http://MadVlad.com

http://www.gotsafelist.com

http://www.gotsafelist.com/complaints_V2.php?id=richmac

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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.

#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 by spudw2k

Share this post


Link to post
Share on other sites

Thank you all for the help. i have used the input i got from you to do what i needed.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0