Find the answer to your Linux question:
Results 1 to 4 of 4
Does anyone have some code to extract certain fields from a delimited file? I need to extract the email address and send a message to taht address? Cheers...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User Allblack's Avatar
    Join Date
    May 2003
    Location
    Godzone
    Posts
    416

    Extracting fields from a delimited file


    Does anyone have some code to extract certain fields from a delimited file?
    I need to extract the email address and send a message to taht address?

    Cheers
    I am on a journey to mastering Linux and I got a bloody long way to go!!!

  2. #2
    Linux User
    Join Date
    Jan 2003
    Location
    Cardiff, Wales
    Posts
    478

    file

    post the file here or a link to it and I'll write you some quick code.

    basically
    f = open file
    while (! EOF(f))
    temp = get line of text
    tempArray = split temp by delimiter
    emailarray[counter] = tempArray[x]
    counter ++
    end while
    close file

    send email

    If you wish to do it youself then use the algorithm above to complete the task. Php builder has a full php manual (www.phpbuilder.com) also check out www.phpfreaks.com

    good luck

    Kris
    No trees were harmed during the creation of this message. Its made from a blend of elephant tusk and dolphin meat.

  3. #3
    Linux Engineer Giro's Avatar
    Join Date
    Jul 2003
    Location
    England
    Posts
    1,219
    I would
    Code:
    $delimiter = "put delimiter here"; 
    $file = "filename here";
    $email_title = "title here";
    $email_body = "body here";
    
    $fp = fopen($file)
      or die("Canmnot open file?");
    $data = fread($fp, 10000);
    $address = explode($delimiter, $data);
    foreach ($address[0] as $address)
    {
        mail($address, $email_title, $email_body)
          or die("Cannot mail?");
    }

  4. #4
    Linux User Allblack's Avatar
    Join Date
    May 2003
    Location
    Godzone
    Posts
    416
    Thanks guys,

    I will give it a go.

    Cheers
    I am on a journey to mastering Linux and I got a bloody long way to go!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •