[dscng-dev] Error reading corrupt dat files

Bedrich Kosata bedrich.kosata at nic.cz
Thu Jun 14 15:26:21 CEST 2012


Hi John,

thanks for both the bug report and the fix. I will have a look at it and 
patch potential other places where it would be needed.

Best regards

Beda

On 06/14/2012 03:14 PM, John Dickinson wrote:
> Hi,
>
> I hit an error importing a corrupt data file. 1 line in the file was truncated and contained no value.
>
> Here is a quick fix, but I suspect that it needs to be repeated in all the parse_data_file_Xd functions.
>
> diff --git a/import_dsc_dat_files.py b/import_dsc_dat_files.py
> index c54bc4b..d6a8357 100644
> --- a/import_dsc_dat_files.py
> +++ b/import_dsc_dat_files.py
> @@ -752,7 +752,12 @@ value for 'else'. This is probably an error.")
>                   if remap1 is None and data[i].isdigit():
>                       value1 = local_int(data[i])
>                   else:
> -                    value1 = value_to_int(data[i], dim1)
> +                    try:
> +                        value1 = value_to_int(data[i], dim1)
> +                    except:
> +                        print "Error reading line from 2D data file"
> +                        i += 2
> +                        continue
>                   count = local_int(data[i+1])
>                   row.append(((value1,), count))
>                   i += 2
>
> regards
> John
>
>
> ---
> jad at sinodun.com
>
> http://sinodun.com
>
> Sinodun Internet Technologies Ltd.
> Stables 4, Suite 11,
> Howbery Park,
> Wallingford,
> Oxfordshire,
> OX10 8BA,
> U.K.
>
> +44 (0)1491 834957
>
>
>
> _______________________________________________
> dscng-dev mailing list
> dscng-dev at lists.nic.cz
> https://lists.nic.cz/cgi-bin/mailman/listinfo/dscng-dev



More information about the dscng-dev mailing list