I am facing problem with my malfunction csv input file whole reading and which i can deal with by adding "error_bad_lines=False" in my read_csv func to remove those.
But i need to report these many files which is creating the problem, I assumed that i need to catch that exception. And i tried it via using
except pd.parser.CParserError
and
except ExceptionSubclass as exceptionsubclass:
After searching over Internet, in both the cases i am not able to catch this exception, if you have any idea how to report all the malfunction file please let me know.
Error i am getting :
Traceback (most recent call last):File "main.py", line 134, in reading_csvdf = pd.read_csv(absolute_path_of_file, sep=',', dtype=str, keep_default_na=False)data = self._reader.read(nrows)File "pandas/_libs/parsers.pyx", line 890, in pandas._libs.parsers.TextReader.read (pandas/_libs/parsers.c:10862)File "pandas/_libs/parsers.pyx", line 912, in pandas._libs.parsers.TextReader._read_low_memory (pandas/_libs/parsers.c:11138)File "pandas/_libs/parsers.pyx", line 966, in pandas._libs.parsers.TextReader._read_rows (pandas/_libs/parsers.c:11884)File "pandas/_libs/parsers.pyx", line 953, in pandas._libs.parsers.TextReader._tokenize_rows (pandas/_libs/parsers.c:11755)File "pandas/_libs/parsers.pyx", line 2184, in pandas._libs.parsers.raise_parser_error (pandas/_libs/parsers.c:28765)
pandas.errors.ParserError: Error tokenizing data. C error: Expected 7 fields in line 22, saw 8