Compare commits
2 Commits
5333f111dd
...
f3aa4d781b
| Author | SHA1 | Date | |
|---|---|---|---|
| f3aa4d781b | |||
| 4b5f6ab85b |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
app/__pycache__/
|
app/__pycache__/
|
||||||
app/.flask_session/
|
app/.flask_session/
|
||||||
|
.flask_session/
|
||||||
|
venv/
|
||||||
.env
|
.env
|
||||||
|
|||||||
10
app/app.py
10
app/app.py
@ -27,7 +27,7 @@ def get_dataframe(key):
|
|||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
def get_merged_df(table_name):
|
def get_merged_df(table_name): # return table_name: str
|
||||||
"""
|
"""
|
||||||
Return a DataFrame for the given table_name based on Stripe and Raisenow inputs,
|
Return a DataFrame for the given table_name based on Stripe and Raisenow inputs,
|
||||||
enforcing strict one-to-one matching with:
|
enforcing strict one-to-one matching with:
|
||||||
@ -36,7 +36,7 @@ def get_merged_df(table_name):
|
|||||||
- no pandas merge suffixes at all
|
- no pandas merge suffixes at all
|
||||||
- all original columns (including Raisenow's norm_zweck) preserved
|
- all original columns (including Raisenow's norm_zweck) preserved
|
||||||
"""
|
"""
|
||||||
|
print('calculated DataFrame')
|
||||||
# --- load & normalize Stripe ---
|
# --- load & normalize Stripe ---
|
||||||
stripe_import = get_dataframe('stripe_import')
|
stripe_import = get_dataframe('stripe_import')
|
||||||
|
|
||||||
@ -339,10 +339,12 @@ def upload():
|
|||||||
return jsonify({'error': 'No files uploaded'}), 400
|
return jsonify({'error': 'No files uploaded'}), 400
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
|
print('uploading file:', f.filename)
|
||||||
raw = (
|
raw = (
|
||||||
pd.read_csv(f) if f.filename.lower().endswith('.csv') else pd.read_excel(f)
|
pd.read_csv(f) if f.filename.lower().endswith('.csv') else pd.read_excel(f)
|
||||||
)
|
)
|
||||||
raw = raw.dropna(how='all').dropna(axis=1, how='all')
|
raw = raw.dropna(how='all').dropna(axis=1, how='all')
|
||||||
|
print('number of rows:', len(raw))
|
||||||
raw = raw.astype(object).replace({np.nan: None})
|
raw = raw.astype(object).replace({np.nan: None})
|
||||||
cols = list(raw.columns)
|
cols = list(raw.columns)
|
||||||
if cols[:len(STRIPE_STARTING_COLS)] == STRIPE_STARTING_COLS:
|
if cols[:len(STRIPE_STARTING_COLS)] == STRIPE_STARTING_COLS:
|
||||||
@ -367,9 +369,9 @@ def upload():
|
|||||||
@app.route('/get_table')
|
@app.route('/get_table')
|
||||||
def get_table():
|
def get_table():
|
||||||
table = request.args.get('table')
|
table = request.args.get('table')
|
||||||
|
print('get_table:', table)
|
||||||
df = get_merged_df(table)
|
df = get_merged_df(table)
|
||||||
|
print('number of rows:', len(df))
|
||||||
df = df.astype(object).where(pd.notnull(df), None)
|
df = df.astype(object).where(pd.notnull(df), None)
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'columns': list(df.columns),
|
'columns': list(df.columns),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user