Skip to content

Optimize utils.py for Better Performance #100

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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