Skip to content

Auto-detect input format from file extension #158

@vmvarela

Description

@vmvarela

Description

When a file argument has a recognizable extension (.csv, .tsv, .json, .ndjson, .xml), auto-set the input format. -I still works as an override.

Examples

# No -I needed — extension tells sql-pipe it's JSON
sql-pipe data.json 'SELECT * FROM t WHERE score > 80'

# Override when extension is wrong
sql-pipe -I tsv data.txt 'SELECT * FROM t'

Acceptance Criteria

  • File extensions .csv, .tsv, .json, .ndjson, .xml auto-set input format
  • -I flag still works as explicit override
  • Stdin input still defaults to CSV (no filename to inspect)
  • Ambiguous extensions (.txt, .dat) default to CSV
  • All existing tests pass
  • New tests cover auto-detection and override behavior

Notes

  • Implementation: ~30 lines
  • Map file extension to InputFormat enum in argument parser
  • Only applies to file arguments, not stdin
  • Zero new flags, actually removes a flag from common invocations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions