May-07-2021, 07:20 PM
Please consider the following function:
the comma. Hence the call to read_cvs produces the following error message:
Bob
import pandas as pd def read_input(path1, path2): """Concat two paths/strs; yields pandas.DataFrame of indicated file.""" full_input_path = Path(path1, path2) columns = { 'symbol': str, 'num_shares': int } with open(full_input_path) as input_file: # Redirect stderr to something we can report on. stocks_table = None stocks_table = pd.read_csv( input_file, sep=',', names=columns.keys(), index_col=False, # fix data file? #dtype=columns, comment='#', error_bad_lines=False, # fix? warn_bad_lines=True ) # discuss validation return stocks_tableThe file is suppose to have two fields in it, separated by a comma. However, one of the records is missing
the comma. Hence the call to read_cvs produces the following error message:
Output:- VO 5: No data found, symbol may be delisted
Is there a way to find out which record in the input was bad?Bob