Export data to .csv or .xml

Hi everybody,

I’m just new in flightaware.

I’ve just built my first pi-aware station and i try to make an export to a csv file (or xml).
I check on the forum but it was not enough clear. Any idea pls?

Best regards;

WL

What are you trying to export?
If you’re talking about the aircraft passing your station, then you might take a look at this script:

I try to export the data with all the aircraft passing my station (positions, speed, etc) in real time (at the moment or few seconds before the export). In order to make later an automatic export (every 10 minutes maybe or according to an alert such as positions, etc).

I’ld like to integer this informations to elastic search to make a dashboard.

I’m looking the link you send me. Thanks about that.

WL

The link i am sending to you delivers the information only once a day (during the night) so you can process them later.

Realtime information require that you’re accessing the JSON output directly and this requires some programming skills

Another option is the usage of Virtual Radar Server. There is a database option available which stores information about aircraft and flights into a SQLite database. This you can use later for processing the data. With some skills a Dashboard should be possible as well.

1 Like

OK thanks FoxHunter,

I’ll try with Virtual Radar server first.

Have a nice day

Here is a Python program that reads the JSON file from Dump1090 and writes the records to a file. It requires Dictor from dictor · PyPI. There is no error checking.

Dump1090All.py dumps every field in a record. Dump1090.py dumps only the fields I want to see, as often as I want to see them.

I added two T/F fields (mlatProvided & tisbProvided) that say whether the mlat or tisb arrays had any data. I also put a default value of -1 for the seen_pos field instead of a blank if it’s not provided because all positive values will show a position.

# Dump1090_All.py
# Python program to retrieve JSON records from Dump1090 and write them to a file
# Mark Moerman - July 2020
#
# Requires Dictor from https://pypi.org/project/dictor/
#
import json
import urllib.request
import time
import csv
from dictor import dictor
#
# Download URL for raw json object - change to your local network address and dump1090 path
url = "http://192.168.1.16/dump1090-fa/data/aircraft.json"
#
#  A very large number to force initial file write
aircraftCount = 10000000
#
while True:
	data = urllib.request.urlopen(url).read().decode()
	obj = json.loads(data)
	adsb_timestamp = obj['now']
	for item in obj['aircraft']:
		if item['seen'] < 301:  # change this number of seconds since the aircraft was last seen to reduce the number of stale records written to the file
			if aircraftCount > 256000:  # Change this number to the approximate number of lines you would like in a file
				aircraftCount = 0
				outputFile = 'D:/Dump1090/Logs/' + str(int(adsb_timestamp)) + '_all.txt'
				dump1090log = open(outputFile, mode='w', newline='')
				dump1090log_writer = csv.writer(dump1090log,delimiter='\t')
				dump1090log_writer.writerow([\
					'timestamp',\
					'hex',\
					'flight',\
					'alt_baro',\
					'alt_geom',\
					'gs',\
					'ias',\
					'tas',\
					'mach',\
					'track',\
					'track_rate',\
					'roll',\
					'mag_heading',\
					'true_heading',\
					'baro_rate',\
					'geom_rate',\
					'squawk',\
					'emergency',\
					'category',\
					'nav_qnh',\
					'nav_altitude_mcp',\
					'nav_altitude_fms',\
					'nav_heading',\
					'nav_modes',\
					'lat',\
					'lon',\
					'nic',\
					'rc',\
					'seen_pos',\
					'version',\
					'nic_baro',\
					'nac_p',\
					'nac_v',\
					'sil',\
					'sil_type',\
					'gva',\
					'sda',\
					'mlat',\
					'mlatProvided',\
					'tisb',\
					'tisbProvided',\
					'messages',\
					'seen',\
					'rssi'])
#           
			if not item['mlat']:
				mlatProvided = 'F'
			else:
				mlatProvided = 'T'
			if not item['tisb']:
				tisbProvided = 'F'
			else:
				tisbProvided = 'T'
			lastSeenPos = float(dictor(item, 'seen_pos', default='-1'))
			if lastSeenPos < 301:  # Change this number of seconds since the aircraft provided a new position  
				dump1090log_writer.writerow([\
					obj['now'],\
					dictor(item, 'hex', default='FFFFFF'),\
					dictor(item, 'flight', default=''),\
					dictor(item, 'alt_baro', default=''),\
					dictor(item, 'alt_geom', default=''),\
					dictor(item, 'gs', default=''),\
					dictor(item, 'ias', default=''),\
					dictor(item, 'tas', default=''),\
					dictor(item, 'mach', default=''),\
					dictor(item, 'track', default=''),\
					dictor(item, 'track_rate', default=''),\
					dictor(item, 'roll', default=''),\
					dictor(item, 'mag_heading', default=''),\
					dictor(item, 'true_heading', default=''),\
					dictor(item, 'baro_rate', default=''),\
					dictor(item, 'geom_rate', default=''),\
					dictor(item, 'squawk', default=''),\
					dictor(item, 'emergency', default='0'),\
					dictor(item, 'category', default='0'),\
					dictor(item, 'nav_qnh', default=''),\
					dictor(item, 'nav_altitude_mcp', default=''),\
					dictor(item, 'nav_altitude_fms', default=''),\
					dictor(item, 'nav_heading', default=''),\
					dictor(item, 'nav_modes', default=''),\
					dictor(item, 'lat', default=''),\
					dictor(item, 'lon', default=''),\
					dictor(item, 'nic', default=''),\
					dictor(item, 'rc', default=''),\
					dictor(item, 'seen_pos', default='-1'),\
					dictor(item, 'version', default=''),\
					dictor(item, 'nic_baro', default=''),\
					dictor(item, 'nac_p', default=''),\
					dictor(item, 'nac_v', default=''),\
					dictor(item, 'sil', default=''),\
					dictor(item, 'sil_type', default=''),\
					dictor(item, 'gva', default=''),\
					dictor(item, 'sda', default=''),\
					dictor(item, 'mlat', default='NONE'),\
					mlatProvided,\
					dictor(item, 'tisb', default='NONE'),\
					tisbProvided,\
					dictor(item, 'messages', default=''),\
					dictor(item, 'seen', default=''),\
					dictor(item, 'rssi', default='')])
			aircraftCount = aircraftCount + 1
	time.sleep(1)  # Change the number of seconds until the next retrieval of the JSON file
	```
# Dump1090.py
# Python program to retrieve JSON records from Dump1090 and write them to a file
# Mark Moerman - July 2020
#
# Requires Dictor from https://pypi.org/project/dictor/
#
import json
import urllib.request
import time
import csv
from dictor import dictor
#
# Download URL for raw json object - change to your local network address and dump1090 path
url = "http://192.168.1.16/dump1090-fa/data/aircraft.json"
#
#  A very large number to force initial file write
aircraftCount = 10000000
#
while True:
	data = urllib.request.urlopen(url).read().decode()
	obj = json.loads(data)
	adsb_timestamp = obj['now']
	for item in obj['aircraft']:
		if item['seen'] < 1.1:  # change this number of seconds since the aircraft was last seen to reduce the number of stale records written to the file
			if aircraftCount > 256000:  # Change this number to the approximate number of lines you would like in a file
				aircraftCount = 0
				outputFile = 'D:/Dump1090/Logs/' + str(int(adsb_timestamp)) + '.txt'
				dump1090log = open(outputFile, mode='w', newline='')
				dump1090log_writer = csv.writer(dump1090log,delimiter='\t')
				dump1090log_writer.writerow([\
					'timestamp',\
					'hex',\
					'flight',\
					'alt_baro',\
					'alt_geom',\
					'gs',\
#					'ias',\
#					'tas',\
#					'mach',\
					'track',\
#					'track_rate',\
#					'roll',\
#					'mag_heading',\
#					'true_heading',\
#					'baro_rate',\
#					'geom_rate',\
					'squawk',\
#					'emergency',\
#					'category',\
#					'nav_qnh',\
#					'nav_altitude_mcp',\
#					'nav_altitude_fms',\
#					'nav_heading',\
#					'nav_modes',\
					'lat',\
					'lon',\
#					'nic',\
#					'rc',\
					'seen_pos',\
#					'version',\
#					'nic_baro',\
#					'nac_p',\
#					'nac_v',\
#					'sil',\
#					'sil_type',\
#					'gva',\
#					'sda',\
#					'mlat',\
					'mlatProvided',\
#					'tisb',\
					'tisbProvided',\
					'messages',\
					'seen',\
					'rssi'])
#
			if not item['mlat']:
				mlatProvided = 'F'
			else:
				mlatProvided = 'T'
			if not item['tisb']:
				tisbProvided = 'F'
			else:
				tisbProvided = 'T'
			lastSeenPos = float(dictor(item, 'seen_pos', default='-1'))
			if lastSeenPos < 1.1:  # Change this number of seconds since the aircraft provided a new position   
				dump1090log_writer.writerow([\
					obj['now'],\
					dictor(item, 'hex', default='FFFFFF'),\
					dictor(item, 'flight', default=''),\
					dictor(item, 'alt_baro', default=''),\
					dictor(item, 'alt_geom', default=''),\
					dictor(item, 'gs', default=''),\
#					dictor(item, 'ias', default=''),\
#					dictor(item, 'tas', default=''),\
#					dictor(item, 'mach', default=''),\
					dictor(item, 'track', default=''),\
#					dictor(item, 'track_rate', default=''),\
#					dictor(item, 'roll', default=''),\
#					dictor(item, 'mag_heading', default=''),\
#					dictor(item, 'true_heading', default=''),\
#					dictor(item, 'baro_rate', default=''),\
#					dictor(item, 'geom_rate', default=''),\
					dictor(item, 'squawk', default=''),\
#					dictor(item, 'emergency', default='0'),\
#					dictor(item, 'category', default='0'),\
#					dictor(item, 'nav_qnh', default=''),\
#					dictor(item, 'nav_altitude_mcp', default=''),\
#					dictor(item, 'nav_altitude_fms', default=''),\
#					dictor(item, 'nav_heading', default=''),\
#					dictor(item, 'nav_modes', default=''),\
					dictor(item, 'lat', default=''),\
					dictor(item, 'lon', default=''),\
#					dictor(item, 'nic', default=''),\
#					dictor(item, 'rc', default=''),\
					dictor(item, 'seen_pos', default='-1'),\
#					dictor(item, 'version', default=''),\
#					dictor(item, 'nic_baro', default=''),\
#					dictor(item, 'nac_p', default=''),\
#					dictor(item, 'nac_v', default=''),\
#					dictor(item, 'sil', default=''),\
#					dictor(item, 'sil_type', default=''),\
#					dictor(item, 'gva', default=''),\
#					dictor(item, 'sda', default=''),\
#					dictor(item, 'mlat', default='NONE'),\
					mlatProvided,\
#					dictor(item, 'tisb', default='NONE'),\
					tisbProvided,\
					dictor(item, 'messages', default=''),\
					dictor(item, 'seen', default=''),\
					dictor(item, 'rssi', default='')])
			aircraftCount = aircraftCount + 1
	time.sleep(1)  # Change the number of seconds until the next retrieval of the JSON file

OK thanks for this informations,

I’ll try to get it.

Have a nice day

WL

OK, it would be a stupid question, but I’m still new with dump1090 and PI-aware.

I’m connected with a TCP connection on data.adsbhub.org. Is it just the data provided by my station that I see or all the stations connected on data.adsbhub.org?

I ask my question because I work also with AIS (ships) connections and users have to add filters (localization, draft, etc) to get data.

Virtual beers offered.

Thanks for your answers

WL

I’m afraid I can’t help with raw data from this site.

it’s ok. Thanks by the way

WL

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.