Results 1 to 8 of 8
  1. #1
    Newbie
    Join Date
    November 11th, 2005
    Posts
    6
    csv import
    I've pieced together a script to import a csv feed into mysql - it keeps throwing errors: "Column count doesn't match value count at row 1." I suspect that the structure of the feed confounds the parsing - it can't tell where one field starts and another begins because the text includes unescaped variables that trigger a response. So I end up with 200 fields rather than seventeen.

    This is my first go integrating these kinds of flat files. How do you wiser minds deal with data that doesn't neatly fit into my little idea of clean variables? What do you do with the feed and what problems have you had building upon it? My script works - just not in this situation. Is there a better approach that I am missing here. Not trying to steal anyone's work or ask someone to solve this for me; but I do suspect that this crowd knows a thing or two more than I do.

    Nice weekends for all.

  2. #2
    ABW Ambassador buy_online's Avatar
    Join Date
    January 18th, 2005
    Location
    Richmond, VA
    Posts
    3,234
    Can you convert to pipe delimited first? The un-escaped characters should remain (if they are important to the cóntent).

    Fred

  3. #3
    Newbie
    Join Date
    November 11th, 2005
    Posts
    6
    Well, I'm not sure one way or the other. I escaped the characters I wanted to keep, and global replaced the rest. Still no dice. Tried CSV and tab delimited - I hoped that escaping the commas then/and//or switching to tab delimited would do it. No such luck.

    To tell the truth, I'm not sure what pipe delimited is. . . Is this how those in-the-know handle this issue. I've dug into the vagaries of the sources of the error - it seems pretty common but none of the solutions inform this kind of problem. I have assumed that everyone writes the feed/or portions of it into their own db - or at least some signigicant part. Is everyone using some third party software? Cause as much as I modify and script my own, I am still at a loss.

    Buy_online: thanks for your response. I will look into the pipe delimited.

  4. #4
    Pimp Duck popdawg's Avatar
    Join Date
    January 18th, 2005
    Location
    Take off eh?
    Posts
    3,249
    | <--- using that as the delimiter instead of a comma or tab is pipe delimited.


    me like pipe .... that ... doesn't sound quite ... ummm ... right.
    ================================================================
    Been away, now I'm back. Not as much, but I'm back & starting from scratch. Where I was, was fantastic. Where I am now, less so. Things have changed, become harder. So have I. Game ON!!!
    ================================================================

  5. #5
    Newbie
    Join Date
    November 11th, 2005
    Posts
    6
    Swell. Thanks. I know pipe and I know delimited. But thanks for clearing it up.

    [upon reading that sounds sarcastic. It wasn't. Thanks for clearing it up.]

  6. #6
    ABW Ambassador buy_online's Avatar
    Join Date
    January 18th, 2005
    Location
    Richmond, VA
    Posts
    3,234
    Quote Originally Posted by popdawg
    | <--- using that as the delimiter instead of a comma or tab is pipe delimited.
    me like pipe .... that ... doesn't sound quite ... ummm ... right.
    Heheheh....

    On another subject, comma delimited for me means more errors. I stay away from feeds like that if I can.

    Fred

  7. #7
    Full Member
    Join Date
    January 17th, 2005
    Posts
    396
    Does the parsing error you are getting mean that your script is having trouble with the first row - which is usually the column headings - I usually stick in a 'skip the first row' step so I don't try to read the headings into my script.

    Charles

  8. #8
    Affiliate Manager
    Join Date
    January 18th, 2005
    Location
    Los Angeles, California
    Posts
    1,913
    Quote Originally Posted by twoseven
    I've pieced together a script to import a csv feed into mysql - it keeps throwing errors: "Column count doesn't match value count at row 1." I suspect that the structure of the feed confounds the parsing - it can't tell where one field starts and another begins because the text includes unescaped variables that trigger a response. So I end up with 200 fields rather than seventeen.
    CSV is a notoriously horrible format. There is no true standard, and not even Microsoft implements it consistently among its products. There's a lot of code for parsing CSV available online, and a lot of discussion about how annoying it is to try to handle all the many exceptions that tend to come up with that format.

    If the vendor has a feed available in any more reasonable format, like pipe- or tab-delimited, you'll have a better time parsing those.

    If the vendor doesn't currently offer an alternative format, you would do them and their other affiliates a favor to suggest it.

    Since commas and quotes commonly appear in text, using commas and quotes to delimit data is just silly. It's a sad statement about the computing industry that such a dumb format has remain popular as long as it has.
    Richard Gaskin
    Developer of WebMerge: Publish any data feed on any site
    http://www.fourthworld.com

  9. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Featured: Help! Anyone know about wp all import?
    By HHOA in forum Programming / Datafeeds / Tools
    Replies: 25
    Last Post: September 13th, 2014, 08:42 PM
  2. Import images to Adwords Editor via csv file?
    By referist in forum Search Engine Optimization
    Replies: 0
    Last Post: September 19th, 2010, 06:11 PM
  3. import mysql
    By Devanand in forum Midnight Cafe'
    Replies: 11
    Last Post: August 30th, 2008, 10:03 AM
  4. Wordpress Import help
    By loxly in forum Midnight Cafe'
    Replies: 9
    Last Post: August 9th, 2007, 08:46 AM

Posting Permissions

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