Code Monkey home page Code Monkey logo

tram-age's Introduction

Compute age of trams in Russian cities

The most of systems of public transportation in Russia uses ancient wagons. List of passenger vehicles by particular city is available at URL like https://transphoto.org/list.php?serv=0&cid=54&t=1, list of Russian cities available at https://transphoto.org/country/1/

This program fetches data for specified city and type of transportation and then make some statistical computation.

Preparing

make prepare
. env/bin/activate

or

sudo apt install pip3-venv
python3 -m venv env
. env/bin/activate
pip install -r requirements.txt

Usage

compute.py [-h] [-c CITY] [-t TYPE] [-l LANGUAGE]

Optional arguments

  • -h, --help — show help message and exit
  • -c CITY, --city CITY — number or name (default city is Moscow)
  • -t TYPE, --type TYPE — transportation type (digit 1 to 9 or name, default value is tram)
  • -l CODE, --language CODEISO 639-1 language code (default is ru for Russian)
  • -o FILE, --output FILE — output frequency table to file. Format detected by filename without case sensitivity.

File formats

  • CSV — Comma Separated Values — file.csv
  • HTML — Hypertext Markup Language — file.htm, file.html
  • JSON — JavaScript Notation Object — file.json, file.js
  • Microsoft Excel — file.xls (legacy), file.xlsx

Examples

It's possible to use digital IDs

$ python compute.py --city 229 --type 2
Миасс, троллейбус
-----------------
1987       1 #
1988       3 ###
1989       1 #
1992       2 ##
1993       2 ##
2002       2 ##
2004       1 #
2005       1 #
2006       1 #
2007       1 #
2008       3 ###
2009       6 ######
2011       1 #
2020       2 ##
------------
Total     28
Mean: 2002.6, median: 2006.5, modes: [2009]

or human readable names

$ python compute.py --city Ekb --type metro --language en
Yekaterinburg, metro
--------------------
1988       6 ######
1989      39 #######################################
2011       8 ########
2019       8 ########
------------
Total     61
Mean: 1995.7, median: 1989.0, modes: [1989]

Names can be specified in English or in Russian. There are aliases for cities and types for example:

  • metro = metropolitain = subway = underground
  • tramway = tram = tm
  • SPb = Saint Petersburg = Petersburg

See also

Author

Alexander Sapozhnikov http://shoorick.ru/ [email protected]

tram-age's People

Contributors

shoorick avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

tram-age's Issues

Wrong year parsing

Different languages have different date formats: mm.YYYY for Russian but YYYY-mm for Lithuanian:

$ python3 compute.py -l lt -c zlatoust
Zlatoust, tramvajus
-------------------
0-04       1 #
1978       1 #
1981       1 #
1985       2 ##
1986       1 #
1988       1 #
1992       2 ##
1995       4 ####
1996       2 ##
1997       2 ##
2-08       1 #
2000       2 ##
2002       1 #
2004       1 #
2008       1 #
2009       3 ###
3-10       1 #
5-04       1 #
5-06       1 #
7-12       1 #
8-04       1 #
------------
Total     31

So year should be extracted via regular expression \d{4} instead of four last characters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.