sas7bdat 2.2.2 Not Working With Some

Issue #43 new
Former user created an issue

Hi,

The version 2.2.2. is not working with a number of sas7bdat files I tried. Please see attached.

Regards.

Comments (1)

  1. Jared Hobbs repo owner

    Looks like we're getting an OverflowError when trying to parse the dates from those files. This patch will get past the error but I'm not sure what the resulting data is supposed to look like so I won't release this yet. Feel free to submit a PR with a proper fix.

    diff --git a/sas7bdat.py b/sas7bdat.py
    index 02f9cee..6cadb87 100644
    --- a/sas7bdat.py
    +++ b/sas7bdat.py
    @@ -486,7 +486,11 @@ SAS7BDAT object
                 except OverflowError:
                     # Some data sets flagged with a date format are actually
                     # stored as datetime values
    -                val = datetime(1960, 1, 1) + timedelta(seconds=val)
    +                try:
    +                    val = datetime(1960, 1, 1) + timedelta(seconds=val)
    +                except OverflowError:
    +                    self.logger.error('failed to parse date from given value.')
    +                    val = None
             return val
    
         def readlines(self):
    
  2. Log in to comment