Skip to content

Instantly share code, notes, and snippets.

@pierwill
Forked from jsvine/SIPRI-arms-transfer.md
Last active December 11, 2017 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pierwill/42347b97a5a372182b352665311fdcfc to your computer and use it in GitHub Desktop.
Save pierwill/42347b97a5a372182b352665311fdcfc to your computer and use it in GitHub Desktop.
How to download SIPRI arms transfer data as a CSV file instead of a rich-text file.

The Stockholm International Peace Research Institute's Arms Transfers Database provides a tool to download the data. By default, that output is an .rtf rich-text file — not so easy to analyze with your favorite spreadsheet or statistics software. Luckily, getting a CSV of the data isn't very difficult. Here's how.

To get all transfers for 2016, by seller, run this command in your terminal:

curl http://armstrade.sipri.org/armstrade/html/export_trade_register.php --compressed \
    --data 'low_year=2016' \
    --data 'high_year=2016' \
    --data 'seller_country_code=' \
    --data 'buyer_country_code=' \
    --data 'armament_category_id=any' \
    --data 'buyers_or_sellers=sellers' \
    --data 'filetype=csv' \
    --data 'include_open_deals=on' \
    --data 'sum_deliveries=on' \
    --data 'Submit4=Download' \
> sipri-arms-by-seller-2016.csv
  • To adjust the timespan, change the low_year and/or high_year variables. E.g., 'low_year=2010'.
  • To get data only for specific countries, add their three-letter codes to the seller_country_code and/or buyer_country_code variables, with each country code separated by a space. E.g., focus on U.S. and Canadian sales, use 'seller_country_code=USA CAN'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment