unstructured
21df17f7 - fix: consider all the required lines instead of first line to detect file type as CSV (#1728)

Commit
2 years ago
fix: consider all the required lines instead of first line to detect file type as CSV (#1728) Current file detection logic for csv in file_utils/filetype.py is not considering all the lines for counting the no. of comma's, it is considering just the first line which will return always return true ``` lines = lines[: len(lines)] if len(lines) < 10 else lines[:10] header_count = _count_commas(lines[0]) if any("," not in line for line in lines): return False return all(_count_commas(line) == header_count for line in lines[:1]) ``` fixed issue by considering all the lines except the first line as shown below ``` lines = lines[: len(lines)] if len(lines) < 10 else lines[:10] header_count = _count_commas(lines[0]) if any("," not in line for line in lines): return False return all(_count_commas(line) == header_count for line in lines[1:]) ```
Author
Parents
Loading