Skip to content

Colinho22/Trade_Data_Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trade Data Analyzer

This project allows for the analysis of trade data as reported by the United Nations and available through UN Comtrade. Additional data was added using the SPARQL endpoint of Wikidata. After aggregation of the data, you can then explore using a locally hosted Streamlit dashboard.

dashboard


Note

After downloading this repository as is, a version of the project can be run immediately. However, there is no direct connection to UN Comtrade, as this would violate their use and re-dissemination policy.



Requirements

  • Python 3.12
  • packages within requirements.txt
  • locally deployed Apache Jena Fuseki server (app.py is querying towards localhost:3030)
  • UN Comtrade data


Content

This project contains python scripts, a .csv file with some example data from UN comtrade and an empty .ttl file. They are structured within this repository as follows:

  • dashboard
    • app.py #streamlit dashboard
  • data
    • country_ontology.py #ontology for RDF graph
    • countrydata.ttl #empty turtle file to store data from main.py
    • main.py #script to aggregate data from wikidata and .csv to countrydata.ttl
    • plasticstraw.py #script to purge countrydata.ttl
    • sircalcalot.py #script to enhance countrydata.ttl with trade balance calculations
    • uncomtrade.csv #data downloaded from UN comtrade for the years 2014-2023
    • wikidata_queries.py #SPARQL queries for wikidata


Instructions

To be able to start the dashboard you need to execute the following steps:

  1. get the UN Comtrade data and save it into .csv OR use data from this repo
  2. run main.py
  3. run sircalcalot.py
  4. install1 and run2 local Fuseki server
  5. upload countrydata_calculated.ttl3 to Fuseki as countrydata_calculated4
  6. run app.py

Streamlit then deploys the dashboard to http://localhost:8501/ and is ready for exploration.

Footnotes

  1. check Apache Jena Fuseki Download here or download using homebrew.

  2. check Fuseki Quickstart or use homebrew via terminal command (macOS) /opt/homebrew/opt/fuseki/bin/fuseki-server

  3. will be generated when executing sircalcalot.py

  4. app.py is querying http://localhost:3030/countrydata_calculated/query

About

Project that allows for the analysis of trade data from UN Comtrade with additional measurements from Wikidata

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages