php script for taking text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajd335
    New Member
    • Apr 2008
    • 123

    php script for taking text

    Hi ,
    i have one file , which contains the result of one field from the database table.
    look like this,
    +---------------+
    | email |
    +---------------+
    | |
    | |
    | |
    | |
    | abc@example.com |
    | ddd@example.com
    ppp@example.com |
    +---------------+

    i want to write a script which can give me results like,


    abc@example.com
    ddd@example.com
    ppp@example.com ..

    I used sed command ,but not worked...
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    No idea.

    Show the code you're using now, and we can help from there.

    Comment

    • ajd335
      New Member
      • Apr 2008
      • 123

      #3
      Hi..My file is like below :

      +------------------+
      | email |
      +------------------+
      | |
      | |
      | |
      | |
      | abc@example.com |
      | email |
      | |
      | |
      | |
      | |
      | abc@example.com |
      | ajan@example.co m |
      | ha@example.com |
      | abcd@example.co m |
      | web@example.com |






      is the table..that is in one text file..
      I just want to have all the email address..

      Code:
      sed -n "/com/p"  result.txt > result.csv
      and it gives me

      | abc @example.com|
      | bbb@example.com |

      something like this..
      m missing something to avoid that extra |..
      plz help..
      Thanks

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        No.
        I mean the code you use to produce that file.
        i.e. the php
        <?php ... ?> that stuff

        Comment

        • ajd335
          New Member
          • Apr 2008
          • 123

          #5
          Originally posted by markusn00b
          No.
          I mean the code you use to produce that file.
          i.e. the php
          <?php ... ?> that stuff

          Hi mark,
          No, it's like i have one php file in which user enters certain things , Then using PHP script all data goes to the databse , From that table i need email field.

          N that is the result.txt file in which i am storing the results from the Select query..

          Hope i make things clear..

          Comment

          • coolsti
            Contributor
            • Mar 2008
            • 310

            #6
            Perhaps you can explain to us why you seem to extract the data from the database to this text file, and then wish to parse the text file to get the email addresses?

            PHP can certainly read your text file and extract the email addresses with the proper scripting, without needing to "leave PHP" to execute the shell command sed. However, it seems to me it would be more efficient and easier to program in the long run if you extracted the email addresses from the database directly with PHP, and not create this text file as middle man.

            Comment

            • TheServant
              Recognized Expert Top Contributor
              • Feb 2008
              • 1168

              #7
              Originally posted by ajd335
              Hi mark,
              No, it's like i have one php file in which user enters certain things , Then using PHP script all data goes to the databse , From that table i need email field.

              N that is the result.txt file in which i am storing the results from the Select query..

              Hope i make things clear..

              Hi ajd335,
              The one php file you mentioned, we want that code. The output is of little use, and we do not taylor make code, rather fix code that has already been made and is not working as expected. Hope that helps.

              Comment

              Working...