This commit is contained in:
Lasse Studion 2023-05-04 23:16:02 +02:00
parent d70a34fefa
commit e4e0891e03
2 changed files with 6 additions and 6 deletions

8
app.py
View File

@ -34,9 +34,9 @@ def add_nodes(G, df):
G.add_nodes_from(nodes) G.add_nodes_from(nodes)
return G return G
# Set CSS. # Set oage config and CSS.
st.set_page_config(page_title='CSV→GEXF', page_icon='🎭')
st.markdown(info.css, unsafe_allow_html=True) st.markdown(info.css, unsafe_allow_html=True)
# Print title. # Print title.
st.title("Make :green[GEXF] from :red[CSV]") st.title("Make :green[GEXF] from :red[CSV]")
@ -87,7 +87,6 @@ if files_uploaded:
columns.append("") columns.append("")
preselected_target = len(columns) - 1 preselected_target = len(columns) - 1
print(columns)
st.session_state["target"] = st.selectbox( st.session_state["target"] = st.selectbox(
label="Which one is the target column?", label="Which one is the target column?",
options=columns, options=columns,
@ -101,6 +100,7 @@ if files_uploaded:
else: else:
columns.append("") columns.append("")
preselected_source = len(columns) - 1 preselected_source = len(columns) - 1
st.session_state["source"] = st.selectbox( st.session_state["source"] = st.selectbox(
label="Which one is the source column?", label="Which one is the source column?",
options=columns, options=columns,
@ -141,7 +141,6 @@ if files_uploaded:
) )
df_nodes.set_index("labels", inplace=True) df_nodes.set_index("labels", inplace=True)
gexf_file = "output.gexf"
# Make empty graph. # Make empty graph.
G = nx.MultiDiGraph() G = nx.MultiDiGraph()
@ -156,6 +155,7 @@ if files_uploaded:
graph_text = "\n".join([line for line in nx.generate_gexf(G)]) graph_text = "\n".join([line for line in nx.generate_gexf(G)])
# Download gexf-file. # Download gexf-file.
gexf_file = "output.gexf"
st.download_button( st.download_button(
"Download gexf-file", graph_text, file_name=gexf_file "Download gexf-file", graph_text, file_name=gexf_file
) )

View File

@ -4,8 +4,8 @@ relations_example = 'https://gist.githubusercontent.com/lasseedfast/c8548d13202d
# Make links grey/black. # Make links grey/black.
css = """<style> css = """<style>
a:link {color: black;} a:link {color: grey;}
a:visited {color: black;} a:visited {color: grey;}
a:hover {color: grey;} a:hover {color: grey;}
</style> </style>
""" """