Jump to content

EXTRACT EMAIL FROM TXT FILES


jack87
 Share

Recommended Posts

Hi guys,

i'm new on this forum and on autoit.

I need as soon as possible a program to extract emails, faxes and html websites from .txt files.

i have thousands of these info:(examples)

company 1

adress 1xx

continue adress 1xx

Phone 1xxx

Fax 1xxxx

email 1xxxx

http 1xxxx

company 2

adress 2xx

continue adress 2xx

Phone 2xxx

Fax 2xxxx

email 2xxxx

http 2xxxx

so what strings should i create to extract the files and collect them on a new .txt file?

any help will be very useful thanks!

Link to comment
Share on other sites

#include <File.au3>
Global $aRet[1], $email = StringRegExp(FileRead(@DesktopDir&"\company.txt"),"(?<=email\s)([\w\d\.\-]+\@[\w\d\-]+(\.\w+){1,2})",3)
ReDim $aRet[Floor(UBound($email)-1 /2)]
For $i = 0 to UBound($email)-1 Step 2
    $aRet[$i/2] = $email[$i]
Next
_FileWriteFromArray(@DesktopDir&"\companyemails.txt",$aRet)
ShellExecute(@DesktopDir&"\companyemails.txt")

Link to comment
Share on other sites

thank you SEuBo, in which line i have to insert the .txt file i want to get the emails from?

First Line "FileRead(@DesktopDir&"\company.txt")". Just replace that with "FileRead([yourfilepath])"
Link to comment
Share on other sites

I would suggest that you change your text file to a ini format then you can use the iniread, inireadsection etc. Much easier and more powerful than your other option of fileread.

I also would suggest that you do not understand the purpose of this forum. Most people do not take well to scripting demands with as soon as possible tagged to it. The expectation is that you have at least tried to solve the problem and have code to present instead of "so what strings should i create to extract the files". You will get a much better response if you adhere to this.

Picea892

Link to comment
Share on other sites

it gives array error on this part

ReDim $aRet[Floor(UBound($email)-1 /2)]

For $i = 0 to UBound($email)-1 Step 2

$aRet[$i/2] = $email[$i]

what can i change?

Try to replace it with:

For $i = 0 to UBound($email)-1 Step 2
    _ArrayAdd($aRet,$email[$i])
Next

(erase the ReDim [...] too)

Now you also need #include <Array.au3>

This should be a bit slower, but that should not fail at all. (Didnt test it.)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...