some new features
This commit is contained in:
15
utils/file_handling.py
Normal file
15
utils/file_handling.py
Normal file
@ -0,0 +1,15 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
|
||||
def allowed_file(filename):
|
||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in {'csv', 'xls', 'xlsx'}
|
||||
|
||||
def read_file(filepath):
|
||||
if filepath.endswith('.csv'):
|
||||
return pd.read_csv(filepath)
|
||||
else:
|
||||
return pd.read_excel(filepath)
|
||||
|
||||
def save_processed_file(processed_df, filepath):
|
||||
processed_df.to_csv(os.path.join(os.path.dirname(filepath), 'processed_' + os.path.basename(filepath)))
|
||||
return 'processed_' + os.path.basename(filepath)
|
||||
Reference in New Issue
Block a user