Home        Store        Learn        Blog

Export tlog to csv

I am trying to export tlog files using mavlogdump.py but get an error:

C:\Users\bruger\Documents\QGroundControl\Telemetry>mavlogdump.py --types=ATTITUDE --format=csv 2019-06-30\14-24-19.tlog > test.csv
Traceback (most recent call last):
File “C:\Python37\lib\site-packages\pymavlink\mavutil.py”, line 913, in init
self.port = serial.Serial(self.device, 1200, timeout=0,
AttributeError: module ‘serial’ has no attribute ‘Serial’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Python37\Scripts\mavlogdump.py”, line 73, in
zero_time_base=args.zero_time_base)
File “C:\Python37\lib\site-packages\pymavlink\mavutil.py”, line 1638, in mavlink_connection
force_connected=force_connected)
File “C:\Python37\lib\site-packages\pymavlink\mavutil.py”, line 915, in init
except serial.SerialException as e:
AttributeError: module ‘serial’ has no attribute ‘SerialException’

What to do?

I believe you might have done pip install serial instead of pip install pyseral. If this is the case, do pip uninstall serial to remove the wrong package and then pip install pyserial to install the correct one.

Now I get different errors

C:\Users\bruger\Documents\QGroundControl\Telemetry>mavlogdump.py --types=ATTITUDE --format=csv 2019-06-30\14-24-19.tlog > test.csv
Traceback (most recent call last):
File “C:\Python37\Scripts\mavlogdump.py”, line 73, in
zero_time_base=args.zero_time_base)
File “C:\Python37\lib\site-packages\pymavlink\mavutil.py”, line 1638, in mavlink_connection
force_connected=force_connected)
File “C:\Python37\lib\site-packages\pymavlink\mavutil.py”, line 917, in init
raise e
File “C:\Python37\lib\site-packages\pymavlink\mavutil.py”, line 914, in init
dsrdtr=False, rtscts=False, xonxoff=False)
File “C:\Python37\lib\site-packages\serial\serialwin32.py”, line 31, in init
super(Serial, self).init(*args, **kwargs)
File “C:\Python37\lib\site-packages\serial\serialutil.py”, line 240, in init
self.open()
File “C:\Python37\lib\site-packages\serial\serialwin32.py”, line 62, in open
raise SerialException(“could not open port {!r}: {!r}”.format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port ‘2019-06-30\14-24-19.tlog’: FileNotFoundError(2, ‘Den angivne sti blev ikke fundet.’, None, 3)

That is odd. It is trying to open the file as if it were a serial port. Can you check the pymavlink version with pip freeze | grep mav ?

C:\Users\bruger\Documents\QGroundControl\Telemetry>pip freeze
certifi==2018.11.29
cffi==1.11.5
chardet==3.0.4
future==0.17.1
gevent==1.4.0
greenlet==0.4.15
grequests==0.3.0
idna==2.8
iso8601==0.1.12
lxml==4.3.0
pycparser==2.19
pymavlink==2.3.4
pynmea2==1.15.0
pyserial==3.4
PyYAML==5.1
requests==2.21.0
urllib3==1.24.1

I just noticed that you use windows. this could be a Windows-specific issue. Did you try running from the same folder as the log?

In CMD I changed directory to the folder with the tlog files

isn’t 2019-06-30\ a folder in there?

no folders, the filename is 2019-07-17 00-40-24.tlog

Oh no, very simple solution: change filename to 2019-07-17-00-40-24.tlog (no [space])

Thank you for your help!

Great!

The code seems to be failing to detect the file here

I’d also suggest trying to use mavlogdump.py --types=ATTITUDE --format=csv "2019-06-30 14-24-19.tlog" > test.csv with quotes so that backslash is not needed. This way you should not need to rename the file.

Using “” works. So for anyone else, exporting GPS position recorded with Waterlinked Under water GPS is done with this :

mavlogdump.py “QGC_File_Name.tlog” > GPS_File.csv --format csv --types GLOBAL_POSITION_INT

1 Like