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

ValueError from xcontest igc file #4

Open
luigichelli opened this issue May 4, 2019 · 7 comments
Open

ValueError from xcontest igc file #4

luigichelli opened this issue May 4, 2019 · 7 comments

Comments

@luigichelli
Copy link

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'

@ScottStanton
Copy link

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

@ScottStanton
Copy link

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

@syunusic
Copy link

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!

@ScottStanton
Copy link

Can you post lines 107 to 114 from your code?

@syunusic
Copy link

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'])



@ScottStanton
Copy link

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

@syunusic
Copy link

Wow... that was it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants