Skip to content

Python script that parses an Excel table of UserAgents together with their count number to produce statistics on the data

License

Notifications You must be signed in to change notification settings

lucalevi/user-agent-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User-agent-parser

Python script that parses an Excel table of UserAgents together with their count number to produce statistics on the data.

Technology

Interpreter

Python 3.9.7

Python libraries

Install the following libraries before running the script:

  • pandas
    • Install anaconda or miniconda as described here, then open a terminal and run:
    $ conda install pandas
    
  • openpyxl
    • In a terminal, run:
    $ pip install openpyxl
    
  • ua_parser
    • In a terminal, run:
    $ pip install ua_parser
    
  • matplotlib.pyplot
    • In a terminal, run:
    $ python -m pip install -U pip
    $ python -m pip install -U matplotlib 
    

Usage example

  1. Create a folder with ua_parsing.py and your Excel table of UserAgents and relative count number (cnt). We will use Unique_UserAgents_sample.xlsx.
  2. In the script, you can adapt the following lines according to your need, if you want different output file names
outputFileName = 'Unique_UserAgents_parsed.xlsx'
osFile = 'OS_count.xlsx'
browserFile = 'browse_count.xlsx'
deviceFile = 'device_count.xlsx'
plotOsFileName = 'piechart_os.png'
plotBrowserFileName = 'piechart_browser.png'
plotDeviceFileName = 'piechart_device.png'
  1. Open a terminal in the created folder and run:
python3 ua_parsing.py yourfilename.xlsx
  1. If you use the data of this example, you can sobstiute yourfilename.xlsx with Unique_UserAgents_sample.xlsx (which is this file)

  2. As output, you will have an Excel table of the parsed UserAgent data (here an example). Parsed UserAgent data

  3. Afterwards, some statistics are calculated to verify the shares in the data among the Operative Systems, browsers and device type used.

  • The script outputs three Excel tables, one for each share (OS, browser, device type)

Example of output table

  • it plots the data graphically with pie charts. Example of OS share pie chart

What's in this repo

The main files in this repo are:

Which OSs, browsers and device types are included in the data analysis?

OSs:

  • Windows
  • iOS
  • Mac
  • OS X
  • Android
  • Linux

Browsers:

  • Firefox
  • Chrome
  • Safari
  • Opera
  • Edge

Device types:

  • Computer
  • Mobile (smartphones + tablets)

Meta

Author: Luca Iacolettig - iacolettig(dot)luca(at)gmail.com

Distributed under the GNU GPL v3 license. See LICENSE for more information.

About

Python script that parses an Excel table of UserAgents together with their count number to produce statistics on the data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages