Skip to content

Conversation

putbullet
Copy link

Updated utils.py to make CSV-to-SQLite conversion faster and cleaner, keeping it compatible with cli.py and existing tests. No overlap with open PRs (#85, #71, #49, #45).

Changes:

Added chardet to detect CSV encoding in load_csv, cutting down file reads.
Switched to pathlib.Path.rglob in csvs_from_paths for quicker directory scanning.
Used INSERT OR IGNORE in LookupTable.id_for_value to speed up SQL operations.
Generated CREATE TABLE SQL directly in get_create_table_sql, skipping in-memory DB.
Dropped six for Python 3 string handling.
Added context managers for SQLite connections to avoid leaks.

Added chardet to requirements.txt. No changes to cli.py. Should pass existing tests, but I can add new ones if needed. Let me know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant