Skip to main content
The CoroNet License Plate Scanner allows you to export all stored records to a CSV (Comma-Separated Values) file. This enables data analysis in spreadsheet applications, backup creation, and integration with other systems.

Exporting from the Records Page

The easiest way to export your data is through the records viewer interface:
1

Navigate to Records

Go to the records page by clicking ”📜 Ver Registros” from the home page, or navigate directly to /registros.
2

Click Download CSV

At the bottom of the records page, click the “Descargar CSV” button (Download CSV). This button features an upload icon and is styled as a primary action button.
3

Save the File

Your browser will prompt you to save the file as registros.csv. Choose your desired location and save the file.
The exported file contains all records in the database at the time of export. It’s a complete snapshot of your data.

Export Implementation

The export functionality is handled by the /descargar route (app.py:153-156):
@app.route("/descargar")
def descargar():
    ensure_csv()
    return send_file(DATA_PATH, as_attachment=True, download_name="registros.csv")
This implementation:
  • Ensures the CSV file exists before attempting download
  • Sends the file directly from the data directory (data/registros.csv)
  • Uses Flask’s send_file() with as_attachment=True to trigger a browser download
  • Names the downloaded file registros.csv for consistency

CSV File Structure

The exported CSV file contains the following columns:

Column Headers

ColumnDescriptionExample
idUnique sequential record identifier1, 2, 3…
fecha_horaTimestamp when the record was created2024-03-04 15:30:45
matriculaDetected license plate numberABC123, XYZ789
propietarioVehicle owner name (optional)John Doe
tipo_vehiculoVehicle type classification (optional)Sedan, Truck, Motorcycle
observacionAdditional notes or observations (optional)Red color, Damaged bumper
imagenFilename of the stored imagematricula_20240304_153045.jpg

Sample CSV Output

id,fecha_hora,matricula,propietario,tipo_vehiculo,observacion,imagen
1,2024-03-04 15:30:45,ABC123,John Doe,Sedan,Red color,matricula_20240304_153045.jpg
2,2024-03-04 15:35:12,XYZ789,Jane Smith,Truck,Blue with dent,matricula_20240304_153512.jpg
3,2024-03-04 16:20:33,LMN456,,Motorcycle,Black,matricula_20240304_162033.jpg
Empty fields appear as consecutive commas in the CSV file. This is standard CSV format and will be handled correctly by spreadsheet applications.

Using Exported Data

Opening in Spreadsheet Applications

The exported CSV file can be opened in:
  • Microsoft Excel: Double-click the file or use File > Open
  • Google Sheets: Use File > Import > Upload > Select the CSV file
  • LibreOffice Calc: Open directly or use File > Open
  • Apple Numbers: Import via File > Import
Ensure your spreadsheet application is set to UTF-8 encoding when opening the file to properly display special characters in names and observations.

Data Analysis Use Cases

Traffic Analysis

Use the exported data to:
  • Count vehicle visits by license plate number
  • Identify peak hours using the fecha_hora timestamps
  • Analyze vehicle type distribution
  • Track repeat visitors

Record Keeping

The CSV export is useful for:
  • Creating backup copies of your detection records
  • Archiving historical data before system maintenance
  • Sharing records with other departments or systems
  • Compliance and audit trails

Integration with Other Systems

Import the CSV data into:
  • Database management systems (MySQL, PostgreSQL)
  • Business intelligence tools (Tableau, Power BI)
  • Custom Python scripts for advanced analysis
  • Access control systems for automated gate management

Direct File Access

If you need programmatic access to the CSV file:

File Location

The CSV file is stored at:
data/registros.csv
Relative to the application root directory (app.py:18).

Reading with Python

You can directly read the CSV file using Python’s built-in csv module:
import csv

with open('data/registros.csv', 'r', encoding='utf-8') as f:
    reader = csv.DictReader(f)
    for row in reader:
        print(row['matricula'], row['fecha_hora'])

API Access

The /descargar endpoint can also be accessed programmatically:
curl http://localhost:5000/descargar -o registros.csv
This downloads the CSV file via HTTP request, useful for automated backups or remote access.

Export Best Practices

Regular Backups

Export your data regularly to create backups. Consider setting up a scheduled task to automatically download the CSV file daily or weekly.
Recommended backup schedule:
  • Daily: For high-traffic deployments with frequent new records
  • Weekly: For moderate usage scenarios
  • Monthly: For low-volume or archival purposes

Data Validation

After exporting, verify your data:
  • Open the CSV file to ensure all records exported correctly
  • Check that the row count matches your expectations
  • Verify that special characters display properly
  • Confirm that all columns contain expected data

File Management

Organize your exported files:
  • Use descriptive filenames with dates: registros_2024-03-04.csv
  • Store exports in a dedicated backup directory
  • Consider compression for long-term storage: zip registros_2024-03-04.csv
  • Maintain at least 3 backup copies in different locations

Limitations and Considerations

Images Not Included

The CSV export contains only metadata and references to image files:
  • Image filenames are included in the imagen column
  • The actual image files remain in the uploads/ directory
  • To create a complete backup, copy both the CSV file and the entire uploads/ directory
For a complete system backup, use the backup command: tar -czf backup.tar.gz data/registros.csv uploads/

Live Data Export

The export always reflects the current state of the database:
  • Any records deleted after export won’t appear in the file
  • New records added after export require a fresh download
  • The export is a point-in-time snapshot, not a live sync

Large Datasets

For systems with thousands of records:
  • Export files may take a few seconds to generate
  • Large CSV files may open slowly in spreadsheet applications
  • Consider splitting historical data into separate files by date range

Troubleshooting Export Issues

Download Not Starting

If clicking the download button doesn’t trigger a file download:
  • Check that the data/registros.csv file exists
  • Verify the Flask application has read permissions for the data directory
  • Check your browser’s download settings and permissions
  • Try accessing /descargar directly in your browser

Empty CSV File

If the exported file contains only headers:
  • Verify that records exist in the database (check the records page)
  • Ensure records were successfully saved during upload
  • Check the CSV file directly at data/registros.csv

File Encoding Issues

If special characters appear corrupted:
  • The CSV file uses UTF-8 encoding (app.py:28, 33, 38)
  • Ensure your spreadsheet application is set to UTF-8 when opening
  • In Excel, use “Data > From Text/CSV” and specify UTF-8 encoding

Permission Errors

If you see permission denied errors:
  • Verify the Flask application has read access to data/registros.csv
  • Check filesystem permissions: ls -l data/registros.csv
  • Ensure the web server user has appropriate file access rights

Build docs developers (and LLMs) love