SWITRS-to-SQLite
================
**Looking to get right to work with the data? Checkout the cleaned
dataset on Kaggle:** `California Traffic Collision Data from
SWITRS <https://www.kaggle.com/alexgude/california-traffic-collision-data-from-switrs>`__
SWITRS-to-SQLite is a Python3 script that will convert the CSV files
provided by the California Highway Patrol’s `Statewide Integrated
Traffic Records System
(SWITRS) <http://iswitrs.chp.ca.gov/Reports/jsp/userLogin.jsp>`__ and
convert them to an `SQLite3 <https://www.sqlite.org/>`__ database.
Instructions to **download the SWITRS data** can be found
`here <requesting_data.md>`__.
Versioning
----------
This repository follows `Semver <https://semver.org/>`__. I will
increment the **MAJOR** version if a change is backwards incompatible
for either the Python command line or the structure of the output
database.
Installation
------------
The best way to install SWITRS-to-SQLite is with ``pip``:
.. code:: bash
pip install switrs-to-sqlite
This will give you access to the script simply by calling:
.. code:: bash
switrs_to_sqlite --help
You can also clone this repository:
.. code:: bash
git clone https://github.com/agude/SWITRS-to-SQLite.git
cd SWITRS-to-SQLite
./switrs_to_sqlite/switrs_to_sqlite --help
If you clone the repository, SWITRS-to-SQLite can be installed as a
local application using the ``setup.py`` script:
.. code:: bash
git clone https://github.com/agude/SWITRS-to-SQLite.git
cd SWITRS-to-SQLite
./setup.py install
Which, like using ``pip``, will give you access to the script by calling
``switrs_to_sqlite``.
SWITRS-to-SQLite requires only Python3.
Usage
-----
Using SWITRS-to-SQLite is simple, just point it to the unzipped files
from SWITRS and it will run the conversion:
.. code:: bash
switrs_to_sqlite \
CollisionRecords.txt \
PartyRecords.txt \
VictimRecords.txt
The script also supports reading ``gzip``\ ed records files:
.. code:: bash
switrs_to_sqlite \
CollisionRecords.txt.gz \
PartyRecords.txt.gz \
VictimRecords.txt.gz
The conversion process will take about an hour to write the database,
which by default is saved to a file named ``switrs.sqlite3``. The output
file can be changed as follows:
.. code:: bash
switrs_to_sqlite \
CollisionRecords.txt \
PartyRecords.txt \
VictimRecords.txt \
-o new_db_file.sql
The program provides the following help menu when called with
``--help``:
.. code:: bash
usage: switrs_to_sqlite [-h] [-o OUTPUT_FILE]
collision_record party_record victim_record
Convert SWITRS text files to a SQLite database
positional arguments:
collision_record the CollisionRecords.txt file or the same file gzipped
party_record the PartyRecords.txt file or the same file gzipped
victim_record the VictimRecords.txt file or the same file gzipped
optional arguments:
-h, --help show this help message and exit
-o OUTPUT_FILE, --output-file OUTPUT_FILE
file to save the database to
Unit Tests
----------
SWITRS-to-SQLite uses ``pytest`` to run unit tests (contained in the
``tests`` folders). To run the tests, run this command from the base
directory:
.. code:: bash
python3 -m pytest -v
Raw data
{
"_id": null,
"home_page": "https://github.com/agude/SWITRS-to-SQLite",
"name": "switrs-to-sqlite",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.8",
"maintainer_email": null,
"keywords": "switrs, sqlite, data",
"author": "Alexander Gude",
"author_email": "alex.public.account@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d2/0a/d72fa25804d87bbc43486ae1c4f1a0a9dd7fcbed430ec9e3e9c2fb82afcb/switrs_to_sqlite-4.1.3.tar.gz",
"platform": "any",
"description": "SWITRS-to-SQLite\n================\n\n**Looking to get right to work with the data? Checkout the cleaned\ndataset on Kaggle:** `California Traffic Collision Data from\nSWITRS <https://www.kaggle.com/alexgude/california-traffic-collision-data-from-switrs>`__\n\nSWITRS-to-SQLite is a Python3 script that will convert the CSV files\nprovided by the California Highway Patrol\u2019s `Statewide Integrated\nTraffic Records System\n(SWITRS) <http://iswitrs.chp.ca.gov/Reports/jsp/userLogin.jsp>`__ and\nconvert them to an `SQLite3 <https://www.sqlite.org/>`__ database.\n\nInstructions to **download the SWITRS data** can be found\n`here <requesting_data.md>`__.\n\nVersioning\n----------\n\nThis repository follows `Semver <https://semver.org/>`__. I will\nincrement the **MAJOR** version if a change is backwards incompatible\nfor either the Python command line or the structure of the output\ndatabase.\n\nInstallation\n------------\n\nThe best way to install SWITRS-to-SQLite is with ``pip``:\n\n.. code:: bash\n\n pip install switrs-to-sqlite\n\nThis will give you access to the script simply by calling:\n\n.. code:: bash\n\n switrs_to_sqlite --help\n\nYou can also clone this repository:\n\n.. code:: bash\n\n git clone https://github.com/agude/SWITRS-to-SQLite.git\n cd SWITRS-to-SQLite\n ./switrs_to_sqlite/switrs_to_sqlite --help\n\nIf you clone the repository, SWITRS-to-SQLite can be installed as a\nlocal application using the ``setup.py`` script:\n\n.. code:: bash\n\n git clone https://github.com/agude/SWITRS-to-SQLite.git\n cd SWITRS-to-SQLite\n ./setup.py install\n\nWhich, like using ``pip``, will give you access to the script by calling\n``switrs_to_sqlite``.\n\nSWITRS-to-SQLite requires only Python3.\n\nUsage\n-----\n\nUsing SWITRS-to-SQLite is simple, just point it to the unzipped files\nfrom SWITRS and it will run the conversion:\n\n.. code:: bash\n\n switrs_to_sqlite \\\n CollisionRecords.txt \\\n PartyRecords.txt \\\n VictimRecords.txt\n\nThe script also supports reading ``gzip``\\ ed records files:\n\n.. code:: bash\n\n switrs_to_sqlite \\\n CollisionRecords.txt.gz \\\n PartyRecords.txt.gz \\\n VictimRecords.txt.gz\n\nThe conversion process will take about an hour to write the database,\nwhich by default is saved to a file named ``switrs.sqlite3``. The output\nfile can be changed as follows:\n\n.. code:: bash\n\n switrs_to_sqlite \\\n CollisionRecords.txt \\\n PartyRecords.txt \\\n VictimRecords.txt \\\n -o new_db_file.sql\n\nThe program provides the following help menu when called with\n``--help``:\n\n.. code:: bash\n\n usage: switrs_to_sqlite [-h] [-o OUTPUT_FILE]\n collision_record party_record victim_record\n\n Convert SWITRS text files to a SQLite database\n\n positional arguments:\n collision_record the CollisionRecords.txt file or the same file gzipped\n party_record the PartyRecords.txt file or the same file gzipped\n victim_record the VictimRecords.txt file or the same file gzipped\n\n optional arguments:\n -h, --help show this help message and exit\n -o OUTPUT_FILE, --output-file OUTPUT_FILE\n file to save the database to\n\nUnit Tests\n----------\n\nSWITRS-to-SQLite uses ``pytest`` to run unit tests (contained in the\n``tests`` folders). To run the tests, run this command from the base\ndirectory:\n\n.. code:: bash\n\n python3 -m pytest -v\n",
"bugtrack_url": null,
"license": "GPLv3+",
"summary": "Script for converting SWITRS reports to SQLite.",
"version": "4.1.3",
"project_urls": {
"Homepage": "https://github.com/agude/SWITRS-to-SQLite"
},
"split_keywords": [
"switrs",
" sqlite",
" data"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ac8e56fa5d44f4d14245d7d27e1b4fe460cb1705fcfdbf236f364e9869b98abe",
"md5": "da90f4f9d7d6123d727567d42764e32d",
"sha256": "9b22ad46ac834c3f2297465b69e107f85cb6736cc5b23fe8dc0a2884ecc5140f"
},
"downloads": -1,
"filename": "switrs_to_sqlite-4.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "da90f4f9d7d6123d727567d42764e32d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.8",
"size": 33892,
"upload_time": "2025-02-02T23:49:29",
"upload_time_iso_8601": "2025-02-02T23:49:29.889481Z",
"url": "https://files.pythonhosted.org/packages/ac/8e/56fa5d44f4d14245d7d27e1b4fe460cb1705fcfdbf236f364e9869b98abe/switrs_to_sqlite-4.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d20ad72fa25804d87bbc43486ae1c4f1a0a9dd7fcbed430ec9e3e9c2fb82afcb",
"md5": "f39f5032196e652cb5997fa49c994877",
"sha256": "cc152e5ced0c7a2daf2e39f5db0e177b1041525999a4b6b61ca0974734069088"
},
"downloads": -1,
"filename": "switrs_to_sqlite-4.1.3.tar.gz",
"has_sig": false,
"md5_digest": "f39f5032196e652cb5997fa49c994877",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.8",
"size": 41531,
"upload_time": "2025-02-02T23:49:31",
"upload_time_iso_8601": "2025-02-02T23:49:31.978113Z",
"url": "https://files.pythonhosted.org/packages/d2/0a/d72fa25804d87bbc43486ae1c4f1a0a9dd7fcbed430ec9e3e9c2fb82afcb/switrs_to_sqlite-4.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-02 23:49:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "agude",
"github_project": "SWITRS-to-SQLite",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "switrs-to-sqlite"
}