Skip to content

Autodetect date and datetime fields in CSV for SQLite operations #142

@vmvarela

Description

@vmvarela

Description

The current type inference system only detects TEXT, INTEGER, and REAL. This prevents date columns from being properly operated with SQLite date functions (date(), datetime(), strftime(), etc.).

The goal is to automatically detect common date formats in CSV and create DATE or DATETIME columns in SQLite that allow date operations.

Acceptance Criteria

  • Extend ColumnType enum to include DATE and DATETIME
  • Add isDate() and isDateTime() detection functions for common formats (YYYY-MM-DD, DD/MM/YYYY, etc.)
  • Modify inferTypes() to prioritize date detection before number
  • Update createTable() to generate DATE/DATETIME columns in SQLite
  • Update insertRowTyped() to convert values to ISO 8601 format that SQLite expects
  • Maintain backward compatibility (--no-type-inference still works)
  • Unit tests for the new format detectors

Notes

Formats to support initially:

  • DATE: YYYY-MM-DD, DD/MM/YYYY, DD-MM-YYYY
  • DATETIME: YYYY-MM-DD HH:MM:SS, YYYY-MM-DDTHH:MM:SS, DD/MM/YYYY HH:MM

The current 100-row buffer for inference is sufficient for date detection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions