Skip to content

ValueError from xcontest igc file #4

Open

Description

@luigichelli

Hello there, I'm having the following error... any idea? thanks!

Traceback (most recent call last):
File "igc2csv.py", line 253, in
flight = parse_igc(flight)
File "igc2csv.py", line 16, in parse_igc
recordtypes[linetype](line, flight)
File "igc2csv.py", line 101, in logline_H
headertypes[line[1:5]](line[5:], flight)
File "igc2csv.py", line 110, in logline_H_FDTE
flight['flightdate'] = datetime.date(int(line[4:6])+2000, int(line[2:4]), int(line[0:2]))
ValueError: invalid literal for int() with base 10: ':0'

Activity

  1. ScottStanton commented on Jan 1, 2022

    @ScottStanton

    Change line 110 to:
    flight['flightdate'] = datetime.date(int(line[9:11])+2000, int(line[7:9]), int(line[5:7]))

  2. ScottStanton commented on Jan 1, 2022

    @ScottStanton

    I fixed it in my fork of the code. Feel free to commit my changes.
    https://github.com/ScottStanton/IGC2CSV

  3. syunusic commented on Mar 27, 2023

    @syunusic

    Hi! I had the same problem... this is what happened the first time I run it:

    $ python2 IGC2CSV.py /tmp/230325175253.igc 
    Number of arguments: 2
    Argument List: ['IGC2CSV.py', '/tmp/230325175253.igc']
    Single IGC file supplied: /tmp/230325175253.igc
    1 flights ready to process...
    Traceback (most recent call last):
      File "IGC2CSV.py", line 254, in <module>
        flight = parse_igc(flight)
      File "IGC2CSV.py", line 16, in parse_igc
        recordtypes[linetype](line, flight)
      File "IGC2CSV.py", line 101, in logline_H
        headertypes[line[1:5]](line[5:], flight)
      File "IGC2CSV.py", line 110, in logline_H_FDTE
        flight['flightdate'] = datetime.date(int(line[4:6])+2000, int(line[2:4]), int(line[0:2]))
    ValueError: invalid literal for int() with base 10: ':2'
    

    Then I change line 110 as @ScottStanton suggested and this is the error I got now:

    $ python2 IGC2CSV.py /tmp/230325175253.igc 
      File "IGC2CSV.py", line 111
        flight['flightdate'] = datetime.date(int(line[9:11])+2000, int(line[7:9]), int(line[5:7]))
             ^
    IndentationError: expected an indented block
    

    Please help!

  4. ScottStanton commented on Mar 27, 2023

    @ScottStanton

    Can you post lines 107 to 114 from your code?

  5. syunusic commented on Mar 27, 2023

    @syunusic

    Sure:

    # Date format: DDMMYY
    # (did we learn nothing from Y2K?)
    def logline_H_FDTE(line, flight):
    #  flight['flightdate'] = datetime.date(int(line[4:6])+2000, int(line[2:4]), int(line[0:2]))
    flight['flightdate'] = datetime.date(int(line[9:11])+2000, int(line[7:9]), int(line[5:7]))
      print "Flight date: {}".format(flight['flightdate'])
    
    
    
    
  6. ScottStanton commented on Mar 27, 2023

    @ScottStanton

    Indent the line that start with 'flight' to match the indentation of the 'print' below it.
    Python is very particular about indentation.

  7. syunusic commented on Mar 27, 2023

    @syunusic

    Wow... that was it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions