The `detect-delimiter` Python library, currently at version 0.1.1 and last released in July 2018, provides a simple function to automatically identify the delimiter used in various ad-hoc file formats like CSV or TSV. It primarily operates by counting character frequencies within an input string. The library exposes a single `detect()` function, making it straightforward to use for basic delimiter detection needs. Its release cadence appears to be sporadic or ceased, indicating a stable but not actively developed state.
pip install detect-delimiterVerified import paths — ran on the pinned version, not inferred.
The `detect()` function is the primary entry point. It takes the text as a string and can optionally take `whitelist` (a list of characters to prioritize), `blacklist` (characters to ignore), and `default` (a value to return if no delimiter is found) parameters.
Use the `blacklist` parameter to explicitly include characters for consideration, for example: `detect(text, blacklist=[])` to remove all default blacklisted characters, or `detect(text, whitelist=['.'])` to force checking for a period.
For robust CSV parsing that respects quoting and escaping, consider using Python's built-in `csv.Sniffer` or a more advanced library like `CleverCSV`.
For files with multi-character delimiters, manual parsing or a custom solution will be required, as this library is not suitable.
For files known to follow CSV standards with quoting, use Python's `csv.Sniffer`. If a simplified approach is still desired and the problem persists, use the `whitelist` parameter with only the *true* expected delimiters, e.g., `detect(text, whitelist=[';'])`.
Explicitly provide a `whitelist` parameter with the characters you expect to be delimiters (e.g., `detect(text, whitelist=['|', '~'])`) or adjust the `blacklist` if characters are being incorrectly ignored (e.g., `detect(text, blacklist=[])`).
Narrow down the possibilities using the `whitelist` parameter, for example, `detect(text, whitelist=[';', '|'])`. For highly ambiguous cases, manual inspection or a more context-aware parsing library might be needed.
No dependency data recorded yet.