Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

File Parsing and emailing

File Parsing and emailing

File Parsing and emailing

I am trying to read chunks of data from a file and emailing parts of it to certain users. I can get the email done but I can't figure out how to get my data out!
I have markers in a flat file to signify the beginning of my data, the username I'll mail to and then a block of data.

I need to start at ##BEGIN, get the username from #NAME=mailuser, and then pipe all the data between #NAME=mailuser and ##END into a mail message, then start over until I reach the end of my file.

Any help is welcomed!!

My data file is like so:


Bunch of data goes here
and here.. this is still mailsuers' data


This is where I put mailusers2's data


RE: File Parsing and emailing

Hmmmm.... I've had to do something similar in the past in a previous job, and I don't have the code available. However, IIRC, the following "pseudo-code" is pretty much what I did...

open file

while read lines from file
if (line == start pattern && $In_Block_Of_Data == 0)
$In_Block_Of_Data = 1
continue # To go on to next line in file.
if (line == end pattern && $In_Block_Of_Data == 1)
$In_Block_Of_Data = 0
continue # To read next line in file.
if ( $In_Block_Of_Data == 1)
# Do data processing here.
# Some kind of unexpected situation occurred, eg block start with no end.
# Check and deal with it.
end while

There's probably an easier way of doing this, but this worked for me at the time when I needed it. Hope it helps.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close