Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing a file timestamp in getfiledate() #85

Open
peterk opened this issue Aug 2, 2024 · 0 comments
Open

Error parsing a file timestamp in getfiledate() #85

peterk opened this issue Aug 2, 2024 · 0 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@peterk
Copy link

peterk commented Aug 2, 2024

Thank you for your great project. I followed the guide to add tag blocks to a simple AIS string from the https://github.com/GlobalFishingWatch/ais-tools project.

$ echo '!AIVDM,1,1,,A,15NTES0P00J>tC4@@FOhMgvD0D0M,0*49' | ais-tools add-tagblock -s my-station > datesample.nm4

The resulting file contains the single line:

\c:1722621763484,s:my-station,T:2024-08-02 18.02.43*26\!AIVDM,1,1,,A,15NTES0P00J>tC4@@FOhMgvD0D0M,0*49

I tried the following script using aisdb to load the file into an sqlite db:

import aisdb
filepaths=['./datesample.nm4']

with aisdb.DBConn(dbpath = './datesample.db') as dbconn:
    aisdb.decode_msgs(filepaths=filepaths, dbconn=dbconn, source='TESTING')

This gives the following error:

generating file checksums...
checking file dates...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/.../aisdb/database/decoder.py", line 249, in decode_msgs
    filedates = [getfiledate(f) for f in raw_files]
  File "/.../aisdb/database/decoder.py", line 249, in <listcomp>
    filedates = [getfiledate(f) for f in raw_files]
  File "/.../aisdb/proc_util.py", line 275, in getfiledate
    fdate = datetime.fromtimestamp(epoch).date()
ValueError: year 56557 is out of range

I expected the file to be parsed and loaded into the db.

Running Python 3.10.12 on macOS.

@gabrielspadon gabrielspadon added the bug Something isn't working label Aug 16, 2024
@gabrielspadon gabrielspadon added the duplicate This issue or pull request already exists label Sep 17, 2024
@tsuzzy tsuzzy mentioned this issue Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants