A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: CSV Issue with PHP

  1. #1
    Domo Arigato! Ultima Designs's Avatar
    Join Date
    Nov 2003
    Location
    Missing in Action
    Posts
    512

    CSV Issue with PHP

    We have written a PHP script that imports your contact list from Microsoft Outlook. It works fine, but Outlook itself presents a problem when exporting the CSV. The script uses explode to form an array, and then identifies each item in the array as one of our fields:

    Code:
    $values = explode("," , $values);
    Pretty simple...but...

    If you have a contact named "Smith, John", it exports that comma there. As a result, using explode breaks up Smith and John and puts them into the array as two separate items rather than one.

    Any ideas on how can we get this to be "Smith, John" instead of "Smith" and "John"? Each value in the Outlook CSV is surrounded by a quotation mark on each side and is separated by commas ("Smith, John","abcd@abcd.net",etc.)
    I really enjoy forgetting. When I first come to a place, I notice all the little details. I notice the way the sky looks. The color of white paper. The way people walk. Doorknobs. Everything. Then I get used to the place and I don't notice those things anymore. So only by forgetting can I see the place again as it really is.

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    there may be a csv module in php to do it right. If not, consider ereg or preg functions to get the "data" items.
    It may still be a problem if quote marks are allowed in the database (and appear doubled in the csv file)

    Musicman

  3. #3
    >>SubKloda<<
    Join Date
    Nov 2002
    Location
    Look Behind You
    Posts
    85
    Hi there,
    you could always use tab delimeted files rather than csv files, when exporting from outlook...

    but then again, if someone puts a tab character in an address field or something, then you're in the same boat

    you'd have thought that microsoft would let export as xml by now, or would that be too useful

    hope this helps,
    Andy

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center