Expected number of fields

Matthew Kelso's Avatar

Matthew Kelso

14 Sep, 2010 02:16 PM via web

I'm trying to replace a dataset with an updated version of the same csv file. The new data comes from a different source and has five fewer columns of data. When I try to replace the dataset, I am given the following message:

There was a problem importing your data: Row 1056 of CSV has 15 fields; expected 20. Try again.

Is there a way around this error message? There are other fields throughout the list that are blank, so I'm not sure why these are such a deal breaker...

  1. Support Staff 2 Posted by widdows on 14 Sep, 2010 02:34 PM

    widdows's Avatar

    Hi Matthew,

    When replacing a dataset, the new dataset needs to have the same
    number of columns as the original. The column headers need to be the
    same and the data types of each column also need to be the same.
    Probably your best bet is to add back the missing columns to the new
    CSV (even if the columns are blank) and make sure all the headers are
    the same as in the original.

    For more detail on replacement datasets, you can view this help
    article from support.rhizalabs.com:

    http://support.rhizalabs.com/faqs/importing-data/new-replacement-series

    Thanks,

    Maryl

  2. Support Staff 3 Posted by higgins on 14 Sep, 2010 02:46 PM

    higgins's Avatar

    The specific problem is that in a CSV file empty cells need to be explicitly delimited with commas.

    Compare these two lines from the file:

    1881545,586293,EAST RESOURCES INC,117-20368,JOHNSON 435 1H OG WELL,41.73381261 ,-77.39962708,Y,3-May-10,Clean Streams Law-General. Used only when a specific CLS code cannot be used,691.1,Administrative,Notice of Violation,997257,722024,,,,,

    1881545,586294,EAST RESOURCES INC,117-20368,JOHNSON 435 1H OG WELL,41.73381261 ,-77.39962708,Y,3-May-10,O&G Act 223-General. Used only when a specific O&G Act code cannot be used,601.101,Administrative,Notice of Violation,997257,722024

    Notice in the first one, there are several trailing commas indicating empty cells for those columns. In the second one (which is the line giving the error) the commas are missing. There are a whole bunch of additional lines that have the same problem following that one.

    The simplest fix is to open a text editor and add the missing commas for the lines that need them. Alternatively, if you open the file in Excel, and add values for the final column in the rows at the end that need them, that should also fix the issue (then save it back out as CSV).

    In the meantime I'll open a case in our bug tracking system: our parser should be able to infer that if there are missing trailing commas we should just insert blank cells.

  3. 4 Posted by Matthew Kelso on 14 Sep, 2010 03:00 PM

    Matthew Kelso's Avatar

    I see. Adding spaces to the cells in question seems to have fixed the problem.

  4. higgins closed this discussion on 14 Sep, 2010 03:15 PM.

  5. Matthew Kelso re-opened this discussion on 14 Sep, 2010 03:38 PM

  6. 5 Posted by Matthew Kelso on 14 Sep, 2010 03:38 PM

    Matthew Kelso's Avatar

    Well it let me do it this time, but the dataset is unusable due to an import error:

    This dataset encountered an error during import.
    Because of the error, this dataset may not be used.

    I guess I will just post it as a new dataset and then delete the old one for the time being.

  7. Support Staff 6 Posted by higgins on 14 Sep, 2010 03:51 PM

    higgins's Avatar

    Looking more closely at the file, it looks like the rows at the end of the file have their fields in the wrong order. In particular, the Longitude field is not in the same place! This is causing an exception at the end of the import phase.

    In Excel, look at rows 1044 and 1045. The Longitude column says something like "KAPLE YX202" and the longitude itself is over in another column which ought to be a date field.

Reply to this discussion

Internal reply

Formatting help or Preview

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Recent Discussions

26 Apr, 2012 05:46 PM
18 Apr, 2012 01:25 AM
30 Mar, 2012 01:57 PM
05 Jun, 2011 06:58 PM
14 Sep, 2010 03:51 PM