Skip to content

Instantly share code, notes, and snippets.

@jsvine
Created November 18, 2015 12:30
Show Gist options
  • Save jsvine/9cb3300588ed402160fe to your computer and use it in GitHub Desktop.
Save jsvine/9cb3300588ed402160fe 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 2014, by seller, run this command in your terminal:

curl http://armstrade.sipri.org/armstrade/html/export_trade_register.php --compressed \
    --data 'low_year=2014' \
    --data 'high_year=2014' \
    --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-2014.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'.
@pierwill
Copy link

Thanks! Any way to include the "comments" field?

@larrybeee
Copy link

Hi, I am going to make an University project with this dataset but the site seems to be down for everyone, is there a way to re-upload the file? Maybe from someone who had download it? Thanks

@larrybeee
Copy link

Nevermind, the site came back up!

@BichTran91
Copy link

Hi Jeremy! I'm so glad to see your post. Could you please explain more about what tool you use to download the data as csv file? Thanks!

@jsvine
Copy link
Author

jsvine commented Sep 24, 2020

Hi @BichTran91, the tool used in the gist above is curl, a command-line utility for fetching HTTP(S) resources: https://en.wikipedia.org/wiki/CURL

Any HTTP library or tool should be able to do the same.

@BichTran91
Copy link

Hi @jsvine, thanks for your reply. I realized that your code runs on Linux (I'm using Windows). I figured out how to do the same using Request in Python. However, the columns I got were 'tidn', 'buyercod', 'sellercod', 'odat', 'odai', 'onum', 'onai', 'ldat', 'term', 'desig2', 'wcat', 'desc', 'coprod', 'nrdel', 'nrdelai', 'delyears', 'buyer', 'seller', 'status', 'tivunit', 'tivorder', 'tivdel'.
Did you encounter this problem? How to get the columns' full names and units?

@jsvine
Copy link
Author

jsvine commented Sep 28, 2020

Hi @BichTran91, unfortunately it has been a long time since I've examined the data or tried to download it. I would recommend examining the SIPRI website (or contacting SIPRI if the website doesn't provide enough information) to get official answers to these questions.

@BichTran91
Copy link

If there is a coding solution for that, I would like to know. Otherwise I agree with you suggestion. Thanks again, @jsvine!

@acoabo
Copy link

acoabo commented Oct 6, 2020

Hi just FYI I just used the code works perfectly! (using mac os 10.14)

thanks a ton, saved a lot of time, greetings from italy (:

@JoePMC
Copy link

JoePMC commented Jul 1, 2025

In case anyone needs it, I ended up manually reconciling SIPRI's country codes with the standard ISO3 country codes as they use their own idiosyncratic list of codes.

Here it is in case anyone might find it useful
Country,ISO3,SIPRI-code
Afghanistan,AFG,AFG
Albania,ALB,ALB
Algeria,DZA,ALG
Andorra,AND,AND
Angola,AGO,ANG
Antigua And Barbuda,ATG,ANT
Argentina,ARG,ARG
Armenia,ARM,ARM
Australia,AUS,AUS
Austria,AUT,AST
Azerbaijan,AZE,AZB
Bahamas,BHS,BAS
Bahrain,BHR,BAH
Bangladesh,BGD,BAN
Barbados,BRB,BAR
Belarus,BLR,BLR
Belgium,BEL,BEL
Belize,BLZ,BLZ
Benin,BEN,BEN
Bhutan,BTN,BHU
Bolivia,BOL,BOL
Bosnia And Herzegovina,BIH,BIH
Botswana,BWA,BOT
Brazil,BRA,BRA
Brunei,BRN,BRU
Bulgaria,BGR,BUL
Burkina Faso,BFA,BF
Burundi,BDI,BDI
Cambodia,KHM,CMB
Cameroon,CMR,CAM
Canada,CAN,CAN
Cape Verde,CPV,CAP
Central African Republic,CAF,CAR
Chad,TCD,CHA
Chile,CHL,CHE
China,CHN,CHI
Colombia,COL,COL
Comoros,COM,COM
Congo,COG,CON
Democratic Republic of the Congo,COD,DRC
Costa Rica,CRI,COS
Côte D'Ivoire,CIV,IVO
Croatia,HRV,CRO
Cuba,CUB,CUB
Cyprus,CYP,CYP
Czechia,CZE,CZR
Denmark,DNK,DEN
Djibouti,DJI,DJI
Dominica,DMA,DCA
Dominican Republic,DOM,DOM
Ecuador,ECU,ECU
Egypt,EGY,EGY
El Salvador,SLV,SAL
Equatorial Guinea,GNQ,EQU
Eritrea,ERI,ERI
Estonia,EST,EST
Ethiopia,ETH,ETH
Fiji,FJI,FJI
Finland,FIN,FIN
France,FRA,FRA
Gabon,GAB,GAB
Gambia,GMB,GAM
Georgia,GEO,GEO
Germany,DEU,FRG
Ghana,GHA,GHA
Greece,GRC,GRE
Grenada,GRD,GND
Guatemala,GTM,GUA
Guinea,GIN,GUI
Guinea-Bissau,GNB,GBI
Guyana,GUY,GUY
Haiti,HTI,HAI
Honduras,HND,HON
Hungary,HUN,HUN
Iceland,ISL,ICE
India,IND,IND
Indonesia,IDN,INS
Iran,IRN,IRA
Iraq,IRQ,IRQ
Ireland,IRL,IRE
Israel,ISR,ISR
Italy,ITA,ITA
Jamaica,JAM,JAM
Japan,JPN,JAP
Jordan,JOR,JOR
Kazakhstan,KAZ,KAZ
Kenya,KEN,KEN
Kiribati,KIR,KIR
North Korea,PRK,KON
South Korea,KOR,KOS
Kosovo,XKX,KSV
Kuwait,KWT,KUW
Kyrgyzstan,KGZ,KYR
Laos,LAO,LAO
Latvia,LVA,LAT
Lebanon,LBN,LEB
Lesotho,LSO,LES
Liberia,LBR,LIB
Libya,LBY,LYA
Liechtenstein,LIE,LIE
Lithuania,LTU,LIT
Luxembourg,LUX,LUX
North Macedonia,MKD,MAC
Madagascar,MDG,MAD
Malawi,MWI,MWI
Malaysia,MYS,MAL
Maldives,MDV,MLV
Mali,MLI,MLI
Malta,MLT,MTA
Marshall Islands,MHL,MAR
Mauritania,MRT,MRA
Mauritius,MUS,MAU
Mexico,MEX,MEX
Micronesia,FSM,MIC
Moldova,MDA,MOL
Monaco,MCO,MCO
Mongolia,MNG,MON
Montenegro,MNE,MTG
Morocco,MAR,MOR
Mozambique,MOZ,MOZ
Myanmar,MMR,MYA
Namibia,NAM,NAM
Nauru,NRU,NAU
Nepal,NPL,NEP
Netherlands,NLD,NET
New Zealand,NZL,NZ
Nicaragua,NIC,NIC
Niger,NER,NIR
Nigeria,NGA,NIG
Norway,NOR,NOR
Oman,OMN,OMA
Pakistan,PAK,PAK
Palau,PLW,PAL
Palestine,PSE,PA
Panama,PAN,PAN
Papua New Guinea,PNG,PAP
Paraguay,PRY,PAR
Peru,PER,PER
Philippines,PHL,PHI
Poland,POL,POL
Portugal,PRT,POR
Qatar,QAT,QAT
Romania,ROU,ROM
Russian Federation,RUS,RUS
Rwanda,RWA,RWA
Saint Kitts And Nevis,KNA,SKN
Saint Lucia,LCA,SLU
Saint Vincent And The Grenadines,VCT,SVG
Samoa,WSM,SAM
San Marino,SMR,SMA
Sao Tome And Principe,STP,STP
Saudi Arabia,SAU,SAU
Senegal,SEN,SEN
Serbia,SRB,SER
Seychelles,SYC,SEY
Sierra Leone,SLE,SIE
Singapore,SGP,SIN
Slovakia,SVK,SLK
Slovenia,SVN,SLO
Solomon Islands,SLB,SOL
Somalia,SOM,SOM
South Sudan,SSD,SSD
South Africa,ZAF,SA
Spain,ESP,SPA
Sri Lanka,LKA,SRI
Sudan,SDN,SUD
Suriname,SUR,SUR
Eswatini,SWZ,SWA
Sweden,SWE,SWE
Switzerland,CHE,SWI
Syria,SYR,SYR
Taiwan,TWN,TAI
Tajikistan,TJK,TAJ
Tanzania,TZA,TAN
Thailand,THA,THA
Timor-Leste,TLS,ET
Togo,TGO,TOG
Tonga,TON,TON
Trinidad And Tobago,TTO,TRI
Tunisia,TUN,TUN
Turkey,TUR,TUR
Turkmenistan,TKM,TRK
Tuvalu,TUV,TUV
Uganda,UGA,UGA
Ukraine,UKR,UKR
United Arab Emirates,ARE,UAE
United Kingdom,GBR,UK
United States,USA,USA
Uruguay,URY,URU
Uzbekistan,UZB,UZB
Vanuatu,VUT,VAN
Venezuela,VEN,VEN
Vietnam,VNM,VN
Yemen,YEM,YEM
Zambia,ZMB,ZAM
Zimbabwe,ZWE,ZIM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment