|
|
|
@ -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 |
|
|
|
) |
|
|
|
) |
|
|
|
|