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