Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usage instructions #3

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,28 @@ See `Meedo::setDatabase` for database structure. Currently stores:
* Boston Traffic Citations (`citations`)
* Log

## Usage
```injectablephp
// Create an Importer and pass the directory that holds the data. The data can be spread across multiple files in the
// directory.
$importer = new CsvImporter(__DIR__ . '/../data/citations/2024/');
// Tell the importer which type of Record to use (must extend Record).
$importer->entityType = Citation::class;

// Create a Storage and set the SQLite database file name (the database can be empty or non-existent as long as the
// directory in which it will live is writable).
$storage = new Storage();
$storage->setDatabase(__DIR__ . '/../data/exports/' . 'test.db');

// Extract the tickets using the importer. The first param is an array that maps the columns in the data to the database
// columns.
$tickets = $importer->extractRecords(Mapper::CITATION_2024, Citation::class);

echo number_format(count($tickets)) . ' tickets to process.' . PHP_EOL;

// Import the extracted tickets.
$importer->importRecords($storage, $tickets, Mapper::CITATION_2024, 100);
```

## Known issues
* Citation data from 2021 (2011 - 2021) doesn't appear to include `year`, `make/model`, or `color` of vehicle.
Loading