npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dapia-project/data-converter

v5.0.0

Published

Lib for convert .sbs file to .csv file and to convert .csv file to .sbs file with JSON or NDJSON

Downloads

59

Readme

Data Converter Tests workflow

Data-Converter

This conversion is for ADS-B data only.
This library contains several conversion tools for ADS-B messages. We find :

  • SBS to JSON
  • JSON to SBS
  • SBS to NDJSON
  • NDJSON to SBS
  • CSV Opensky to JSON
  • JSON to CSV Opensky
  • CSV Opensky to NDJSON
  • NDJSON to CSV Opensky
  • SBS to CSV Opensky
  • CSV Opensky to SBS
  • CSV Drone to SBS
  • SBS to CSV Drone
  • CSV Drone to CSV Opensky
  • CSV Opensky to CSV Drone
  • CSV Drone to JSON
  • JSON to CSV Drone
  • CSV Drone to NDJSON
  • NDJSON to CSV Drone
  • JSON to NDJSON
  • NDJSON to JSON

Setup

Via NPM

npm i @dapia-project/data-converter

By updating package.json

In your package.json, add the following:

{
  "dependencies": {
    "@dapia-project/data-converter": "^5.0.0"
  }
}

Initialization

Import SBS to JSON converter:

import { sbsToJson } from '@dapia-project/data-converter/src/sbsToJson'

const jsonData: string = sbsToJson(content, {saveExtraField : true, mustMerge: false})

Import JSON to SBS converter:

import { jsonToSbs } from '@dapia-project/data-converter/src/jsonToSbs'

const sbsData: string = jsonToSbs(content, {saveExtraField : true, mustMerge: false})

Import SBS to NDJSON converter:

import { sbsToNdjson } from '@dapia-project/data-converter/src/sbsToNdjson'

const ndjsonData: string = sbsToNdjson(content, {saveExtraField : true, mustMerge: false})

Import NDJSON to SBS converter:

import { ndjsonToSbs } from '@dapia-project/data-converter/src/ndjsonToSbs'

const sbsData: string = ndjsonToSbs(content, {saveExtraField : true, mustMerge: false})

Import CSV Opensky to JSON converter:

import { openskyCsvToJson } from '@dapia-project/data-converter/src/openskyCsvToJson'

const jsonData: string = openskyCsvToJson(content, {saveExtraField : true, mustMerge: false})

Import JSON to CSV Opensky converter:

import { jsonToOpenskyCsv } from '@dapia-project/data-converter/src/jsonToOpenskyCsv'

const openskyCsvData: string = jsonToOpenskyCsv(content, {saveExtraField : true, mustMerge: false})

Import CSV Opensky to NDJSON converter:

import { openskyCsvToNdjson } from '@dapia-project/data-converter/src/openskyCsvToNdjson'

const ndjsonData: string = openskyCsvToNdjson(content, {saveExtraField : true, mustMerge: false})

Import NDJSON to CSV Opensky converter:

import { ndjsonToOpenskyCsv } from '@dapia-project/data-converter/src/ndjsonToOpenskyCsv'

const openskyCsvData: string = ndjsonToOpenskyCsv(content, {saveExtraField : true, mustMerge: false})

Import CSV Opensky to SBS converter:

import { openskyCsvToSbs } from '@dapia-project/data-converter/src/openskyCsvToSbs'

const sbsData: string = openskyCsvToSbs(content, {saveExtraField : true, mustMerge: false})

Import SBS to CSV Opensky converter:

import { sbsToOpenskyCsv } from '@dapia-project/data-converter/src/sbsToOpenskyCsv'

const openskyCsvData: string = sbsToOpenskyCsv(content, {saveExtraField : true, mustMerge: false})

Import SBS to CSV Drone converter:

import { sbsToDroneCsv } from '@dapia-project/data-converter/src/sbsToDroneCsv'

const droneCsvData: string = sbsToDroneCsv(content, {saveExtraField : true, mustMerge: false})

Import JSON to CSV Drone converter:

import { jsonToDroneCsv } from '@dapia-project/data-converter/src/jsonToDroneCsv'

const droneCsvData: string = jsonToDroneCsv(content, {saveExtraField : true, mustMerge: false})

Import NDJSON to CSV Drone converter:

import { ndjsonToDroneCsv } from '@dapia-project/data-converter/src/ndjsonToDroneCsv'

const droneCsvData: string = ndjsonToDroneCsv(content, {saveExtraField : true, mustMerge: false})

Import CSV Opensky to CSV Drone converter:

import { openskyCsvToDroneCsv } from '@dapia-project/data-converter/src/openskyCsvToDroneCsv'

const droneCsvData: string = openskyCsvToDroneCsv(content, {saveExtraField : true, mustMerge: false})

Import CSV Drone to SBS converter:

import { droneCsvToSbs } from '@dapia-project/data-converter/src/droneCsvToSbs'

const sbsData: string = droneCsvToSbs(content, {saveExtraField : true, mustMerge: false})

Import CSV Drone to JSON converter:

import { droneCsvToJson } from '@dapia-project/data-converter/src/droneCsvToJson'

const jsonData: string = droneCsvToJson(content, {saveExtraField : true, mustMerge: false})

Import CSV Drone to NDJSON converter:

import { droneCsvToNdjson } from '@dapia-project/data-converter/src/droneCsvToNdjson'

const ndjsonData: string = droneCsvToNdjson(content, {saveExtraField : true, mustMerge: false})

Import CSV Drone to CSV Opensky converter:

import { droneCsvToOpenskyCSV } from '@dapia-project/data-converter/src/droneCsvToOpenskyCsv'

const openskyCsvData: string = droneCsvToOpenskyCsv(content, {saveExtraField : true, mustMerge: false})

Content

Content is a string who represent the content file to convert

Options

For all :

| key | type | use | default value | |-----------------|---------|--------------------------------------------------------------------------------------|---------------| | mustMerge | boolean | Choice to merge messages who are present many times for one couple of icao/timestamp | false | | saveExtraField? | boolean | Choice to have extraField of Format1 in Format2 | false |

Order of fields

For SBS files :

| Number | Field | | -------------- |-------------------------------------| | Field 1 | messageType | | Field 2 | transmissionType | | Field 3 | sessionID | | Field 4 | aircraftID | | Field 5 | icao24 | | Field 6 | flightID | | Field 7 | dateMessageGenerated (AAAA/MM/DD) | | Field 8 | timeMessageGenerated (HH:mm:ss.SSS) | | Field 9 | dateMessageLogged (AAAA/MM/DD) | | Field 10 | timeMessageLogged (HH:mm:ss.SSS) | | Field 11 | callsign | | Field 12 | geoaltitude | | Field 13 | groundspeed | | Field 14 | track | | Field 15 | latitude | | Field 16 | longitude | | Field 17 | vertical_rate | | Field 18 | squawk | | Field 19 | alert | | Field 20 | emergency | | Field 21 | spi | | Field 22 | onground | | Field 23 | haveLabel? | | Field 24 | label? | | Field 23 or 25 | extraField? |


The HaveLabel and Label fields are not required. But if one is present then so is the other.
The ExtraField field is a JSON object that contains information present in a converted csv file not present in sbs file. Here is an example:

{
  "altitude": "",
  "last_position": "",
  "lastcontact": "",
  "hour": ""
}

You can find information about the SBS format here: http://woodair.net/sbs/Article/Barebones42_Socket_Data.htm

For CSV Opensky files :

The order of the fields below is the order when converting SBS to CSV Opensky. However, the order of fields in a CSV Opensky file during a CSV Opensky to SBS conversion does not follow a certain pattern.

| Number | Field | | -------- |----------------| | Field 1 | timestamp | | Field 2 | icao24 | | Field 3 | latitude | | Field 4 | longitude | | Field 5 | groundspeed | | Field 6 | track | | Field 7 | vertical_rate | | Field 8 | callsign | | Field 9 | onground | | Field 10 | alert | | Field 11 | spi | | Field 12 | squawk | | Field 13 | altitude | | Field 14 | geoaltitude | | Field 15 | last_position? | | Field 16 | lastcontact? | | Field 17 | hour? | | Field 18 | extraField? |


The ExtraField field is a JSON object that contains information present in a converted sbs file not present in csv file. It is not mandatory to add this field when converting. Here is an exemple:

{
  "messageType": "",
  "transmissionType": "",
  "sessionID": "",
  "aircraftID": "",
  "flightID": "",
  "emergency": ""
}



For CSV Drone files :

| Number | Field | |----------|---------------------------------| | Field 1 | name | | Field 2 | icao24 | | Field 3 | date (AAAA-MM-DDTHH:mm:ss.SSSZ) | | Field 4 | fixName | | Field 5 | significantPoint | | Field 6 | timeElapsed | | Field 7 | position.latitude | | Field 8 | position.longitude | | Field 9 | position.altitude | | Field 10 | altitudeMax | | Field 11 | airSpeed | | Field 12 | cas | | Field 13 | mach | | Field 14 | heading | | Field 15 | groundspeed | | Field 16 | distanceToNextWaypoint | | Field 17 | flownDistance | | Field 18 | wind.eastward | | Field 19 | wind.northward | | Field 20 | wind.upward | | Field 21 | route | | Field 22 | mass | | Field 23 | isOneWay | | Field 24 | extraField? |

For JSON and NDJSON files :

| Field | |---------------| | timestamp? | | icao24? | | latitude? | | longitude? | | groundspeed? | | track? | | vertical_rate? | | callsign? | | onground? | | alert? | | spi? | | squawk? | | altitude? | | geoaltitude? | | last_position? | | lastcontact? | | hour? | | messageType? | | transmissionType? | | sessionID? | | aircraftID? | | flightID? | | emergency? | | dateMessageGenerated? | | timeMessageGenerated? | | dateMessageLogged? | | timeMessageLogged? | | haveLabel? | | label? | | name? | | date? | | fixName? | | significantPoint? | | timeElapsed? | | position.latitude? | | position.longitude? | | position.altitude? | | altitudeMax? | | airSpeed? | | cas? | | mach? | | heading? | | distanceToNextWaypoint? | | flownDistance? | | wind.eastward? | | wind.northward? | | wind.upward? | | route? | | mass? | | isOneWay? |

Commands line

You can also run a command line conversion like this:

First, download library globally :

npm i @dapia-project/data-converter -g

Then :

data-converter --file "path/to/fileToConvert.ext" --output "path/to/fileWillBeConvert.ext" [--fusion]

Possible extension types are .sbs, .csv, .json and .ndjson
The option --fusion allows you to merge duplicates.
If you wish to convert a file into a Drone CSV file please put the extension .drone.csv to the output file