reading in time values of form HH:MM results in None

Issue #34 resolved
Tylar Murray created an issue

I'm reading in a file which has a column of time values in the format HH:MM (e.g.: 8:15, 14:30, etc), but savReaderWriter yields None for all values in that column.

I'm not very familiar with spss (and I'm using pspp here), but the relevant "variable description" is:

  • Name: Time
  • Type: Date
  • Width: 5
  • Decimals: 0
  • Label: Time of day in one-minute intervals
  • Values: None
  • Missing: None
  • Columns: 8
  • Measure: Scale

Expected behavior is that savReaderWriter would either:

  • include data as a string
  • raise an error and inform me of issue disallowing reading of this column

Any advice on how to get this column into python or what might be going wrong here?

Comments (6)

  1. Albert-Jan Roskam repo owner

    Hi Tylar,

    Are you using v3.3.0? I recently found and removed a bug related to TIME, DTIME ands also to dates/times before 1900 (commit ab9f684). I hope this problem is fixed in the bleeding-edge version. Could you try installing the very latest version? Please let me know whether it's working.

    Best wishes, Albert-Jan

  2. Eric Zhang

    Hi, AJ, I have the some problem. When I try to read the TIME values in format (eg.: HH:MM , HH:MM:SS) It output [None] .

    And I also can not write any TIME values in format (eg.: HH:MM , HH:MM:SS) DATE values in format (eg.: YYYY-MM-DD) is ok.

    Version 3.3.0

    Screen Shot 2015-03-11 at 1.35.25 AM.png

  3. Albert-Jan Roskam repo owner

    Hi Eric,

    Sorry to hear that you're experiencing problems. I think you should install the bleeding edge version.

    I just ran this syntax in PSPP:

    data list free / x.
    begin data
    1
    end data.
    compute dt = time.hms(12, 03, 58).
    formats dt (time40).
    save outfile = "dt.sav".
    

    Then I used SavReader to open the file:

    albertjan@debian:~/nfs/Public/savreaderwriter$ python
    Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
    [GCC 4.7.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from savReaderWriter import SavReader
    >>> import _version
    >>> reader = SavReader("dt.sav")
    >>> reader.all()
    [[1.0, '12:03:58']]
    >>> reader.close()
    >>> _version.get_versions()
    {'version': '3.3.0-247-ga09d894', 'full': 'a09d8942f2b98b9c16a753fd6acd187e07bd6a96'}
    >>> quit()
    albertjan@debian:~/nfs/Public/savreaderwriter$ python3.4
    Python 3.4.2 (default, Nov 21 2014, 20:13:40) 
    [GCC 4.7.2] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from savReaderWriter import SavReader
    >>> reader = SavReader("dt.sav")
    >>> reader.all()
    [[1.0, b'12:03:58']]
    >>> reader.close()
    >>> quit()
    # just to be sure:
    albertjan@debian:~/nfs/Public/savreaderwriter$ git rev-parse HEAD
    a09d8942f2b98b9c16a753fd6acd187e07bd6a96
    
  4. Log in to comment