def load_table_to_df(fp, **kwargs): if fp.endswith('.xls'): result_df = pd.read_excel(fp, **kwargs) elif fp.endswith('.xlsx'): result_df = pd.read_excel(fp, engine='openpyxl', **kwargs) elif fp.endswith('.csv') or fp.endswith('.txt'): result_df = pd.read_csv(fp, **kwargs) elif fp.endswith('.parquet'): result_df = pd.read_parquet(fp, **kwargs) else: return "Wrong file extension" print(' --> Succesfully loaded {}'.format(fp)) return result_df
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter