in reply to Extra Stuff

This is the error I get when the script crashes.
Can't execute statement: ORA-01722: invalid number (DBD ERROR: OCIStmt +Execute)<P> SQL:

Maybe this will shed some light on the subject.

qball~"I have node idea?!"

Replies are listed 'Best First'.
Re: Re: Extra Stuff
by mikfire (Deacon) on Apr 17, 2001 at 02:15 UTC
    I am going to make a bet that this particular record that is causing you problems contains 22 commas, but not 22 fields. I will also guess, without seeing your data set, that one of your fields is a freeform text entry field, followed by some numeric fields.

    Somebody put commas in the freeform field and split() is doing exactly what you asked. Only now, where you expected a number you suddenly have something that is NAN - text most likely. The error is being generated when you promised Oracle that data would be numeric and it now isn't.

    Parsing CSV files can be exceptionally difficult, especially when freeform fields are involved. I do not know if any of the Text::?sv modules can help, but they will likely do better than a simple split().

    If the modules are not an option, then try putting everything into an array and check the number of elements after the split. You can then attempt to fix it ( which I wouldn't recommend ) or kick the record out as an exception and let a human figure it out ( which I would recommend ). Something like this:

    foreach $rec ( @CUSTDATA ) { chomp $rec; my @data = split /,/, $rec; if ( @data > 14 ) { warn "Record $. has too many fields - skipping: $rec\n"; next; } }

    mikfire