Added custom delimiter.
This commit is contained in:
parent
f9a9bec3f6
commit
d47fc3505b
18
app.py
18
app.py
@ -66,7 +66,7 @@ st.markdown(
|
|||||||
with Gephi and [Gephi Light](https://gephi.org/gephi-lite/).*"""
|
with Gephi and [Gephi Light](https://gephi.org/gephi-lite/).*"""
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
#try:
|
||||||
# Print explainer.
|
# Print explainer.
|
||||||
expl = st.expander(label="More info")
|
expl = st.expander(label="More info")
|
||||||
with expl:
|
with expl:
|
||||||
@ -90,20 +90,26 @@ try:
|
|||||||
st.session_state["sep"] = ','
|
st.session_state["sep"] = ','
|
||||||
|
|
||||||
# Ask for separator.
|
# Ask for separator.
|
||||||
|
separators = {'comma ( , )': ',', 'semicolon ( ; )': ';', 'tab ( \u21E5 )': '\t', 'pipe (|)': '|', 'space ( )': ' ', '':''}
|
||||||
sep = st.radio(
|
sep = st.radio(
|
||||||
'Separator in your files:',
|
'Separator in your files:',
|
||||||
options=['comma ( , )', 'semicolon ( ; )', 'tab ( \u21E5 )', 'pipe (|)', 'space ( )'],
|
options=['comma ( , )', 'semicolon ( ; )', 'tab ( \u21E5 )', 'pipe (|)', 'space ( )', 'custom'],
|
||||||
help='What are the values in your files separated with?'
|
help='What are the values in your files separated with?'
|
||||||
)
|
)
|
||||||
|
if sep == 'custom':
|
||||||
|
sep = st.text_input('Custom delimiter:')
|
||||||
|
separators[sep] = sep
|
||||||
|
|
||||||
separators = {'comma ( , )': ',', 'semicolon ( ; )': ';', 'tab ( \u21E5 )': '\t', 'pipe (|)': '|', 'space ( )': ' '}
|
|
||||||
st.session_state["sep"] = separators[sep]
|
st.session_state["sep"] = separators[sep]
|
||||||
|
|
||||||
# Preview file
|
# Preview file
|
||||||
with col2:
|
with col2:
|
||||||
preview = st.button('Preview file.')
|
preview = st.button('Preview file.')
|
||||||
if preview:
|
if preview:
|
||||||
st.dataframe(pd.read_csv(csv_edges, sep=st.session_state["sep"]))
|
try:
|
||||||
|
st.dataframe(pd.read_csv(csv_edges, sep=st.session_state["sep"]), use_container_width=True)
|
||||||
|
except pd.errors.ParserError:
|
||||||
|
st.markdown(':red[Have you selected a correct separator?]')
|
||||||
|
|
||||||
|
|
||||||
files_uploaded = st.button('Done', 'files_uploaded')
|
files_uploaded = st.button('Done', 'files_uploaded')
|
||||||
@ -183,5 +189,5 @@ try:
|
|||||||
)
|
)
|
||||||
st.write('Import the file to Gephi/Gephi Light, or try [Gephisto](https://jacomyma.github.io/gephisto/) to get an idea of the network.')
|
st.write('Import the file to Gephi/Gephi Light, or try [Gephisto](https://jacomyma.github.io/gephisto/) to get an idea of the network.')
|
||||||
|
|
||||||
except:
|
# except:
|
||||||
st.markdown(':red[Something went wrong, please try again or [write to me](https://twitter.com/lasseedfast).]')
|
# st.markdown(':red[Something went wrong, please try again or [write to me](https://twitter.com/lasseedfast).]')
|
Loading…
x
Reference in New Issue
Block a user