Skip to content

Commit

Permalink
Explorer: Fix json export
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Jul 14, 2024
1 parent ff57739 commit 37d633c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Development
***********

- Bump `environs` to <12
- Explorer: Fix json export

0.89.0 (03.07.2024)
*******************
Expand Down
9 changes: 4 additions & 5 deletions wetterdienst/ui/streamlit/explorer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,12 @@ def create_plotly_fig(
if sql_query:
df = duckdb.query(sql_query).pl()
st.dataframe(df, hide_index=True, use_container_width=True)
st.download_button("Download CSV", df.write_csv(), "data.csv", "text/csv")
data_csv = df.write_csv()
st.download_button("Download CSV", data_csv, "data.csv", "text/csv")
data_json = df.with_columns(pl.col("date").map_elements(lambda d: d.isoformat(), return_dtype=pl.Utf8)).write_json()
st.download_button(
"Download JSON",
df.with_columns(pl.col("date").map_elements(lambda d: d.isoformat())).write_json(
pretty=True,
row_oriented=True,
),
data_json,
"data.json",
"text/json",
)
Expand Down

0 comments on commit 37d633c

Please sign in to comment.