Turnkey CSV ImporterInstalls in minutes

SpaceX NASA Launches to the ISS

Load this example in Data Janitor

SpaceX has its flight manifest directly on their website. The objective is to extract NASA launches to the International Space Station and determine the number of days between those launches.

First step is to copy the data from the SpaceX Manifest web page, and paste it into Data Janitor.

Copy/paste SpaceX manifest data into CSVJSON Data Janitor

Second step is to write the JavaScript function to transform that data. It is necessary to sort rows by launch date in order to calculate days elapsed. I wrote a special function sortByDate for sorting. It uses Underscore.js's sortBy to do that. The comparator function uses Moment.js's unix function to convert to a timestamp. Notice that only NASA launches are processed.

function sortByDate(list, column, descending) {
  return _.sortBy(list, function(o) {
    return moment(o[column]).unix() * (descending ? -1 : 1);
  });
}
function process(input, columns) {
  input = sortByDate(input, 'LAUNCH DATE');
  var output = [];
  var lastDate;
  input.forEach(function(inRow, r) {
    if (inRow.CUSTOMER.indexOf('NASA RESUPPLY TO ISS') >= 0) {
      var date = moment(inRow['LAUNCH DATE']);
      outRow = {
        Launch: date.format('LL'),
        'Days since last launch': lastDate ? date.diff(lastDate, 'days') : '',
        Customer: inRow['CUSTOMER'],
        Site: inRow['LAUNCH SITE'],
        Vehicle: inRow['VEHICLE']
      };
      lastDate = date;
      output.push(outRow);
    }
  });
  return sortByDate(output, 'Launch', true);
}

And the output. Notice we are missing flight 7. This relates to flight CRS-7, where Falcon disintegrated 139 seconds into flight on June 28 2015. It took another year (360 days) before the next launch.

1 June 29, 2018 88 NASA RESUPPLY TO ISS (FLIGHT 15) CAPE CANAVERAL (40) DRAGON & FALCON 9
2 April 2, 2018 108 NASA RESUPPLY TO ISS (FLIGHT 14) CAPE CANAVERAL (40) DRAGON & FALCON 9
3 December 15, 2017 123 NASA RESUPPLY TO ISS (FLIGHT 13) CAPE CANAVERAL (40) DRAGON & FALCON 9
4 August 14, 2017 72 NASA RESUPPLY TO ISS (FLIGHT 12) KENNEDY SPACE CENTER (39A) DRAGON & FALCON 9
5 June 3, 2017 104 NASA RESUPPLY TO ISS (FLIGHT 11) KENNEDY SPACE CENTER (39A) DRAGON & FALCON 9
6 February 19, 2017 216 NASA RESUPPLY TO ISS (FLIGHT 10) KENNEDY SPACE CENTER (39A) DRAGON & FALCON 9
7 July 18, 2016 101 NASA RESUPPLY TO ISS (FLIGHT 9) CAPE CANAVERAL (40) DRAGON & FALCON 9
8 April 8, 2016 360 NASA RESUPPLY TO ISS (FLIGHT 8) CAPE CANAVERAL (40) DRAGON & FALCON 9
9 April 14, 2015 94 NASA RESUPPLY TO ISS (FLIGHT 6) CAPE CANAVERAL (40) DRAGON & FALCON 9
10 January 10, 2015 111 NASA RESUPPLY TO ISS (FLIGHT 5) CAPE CANAVERAL (40) DRAGON & FALCON 9
11 September 21, 2014 156 NASA RESUPPLY TO ISS (FLIGHT 4) CAPE CANAVERAL (40) DRAGON & FALCON 9
12 April 18, 2014 413 NASA RESUPPLY TO ISS (FLIGHT 3) CAPE CANAVERAL (40) DRAGON & FALCON 9
13 March 1, 2013 144 NASA RESUPPLY TO ISS (FLIGHT 2) CAPE CANAVERAL (40) DRAGON & FALCON 9
14 October 8, 2012 NASA RESUPPLY TO ISS (FLIGHT 1) CAPE CANAVERAL (40) DRAGON & FALCON 9