Spaces:
Sleeping
Sleeping
poemsforaphrodite
commited on
Commit
•
f4ca6bd
1
Parent(s):
501a450
Update app.py
Browse files
app.py
CHANGED
@@ -481,10 +481,18 @@ def show_tabular_data(df, co):
|
|
481 |
for col, header in zip(cols, headers):
|
482 |
col.write(f"**{header}**")
|
483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
# Display each row
|
485 |
for index, row in df.iloc[start_idx:end_idx].iterrows():
|
486 |
cols = st.columns([3, 2, 1, 1, 1, 1, 1, 1])
|
487 |
-
cols[0].write(row['page'])
|
488 |
cols[1].write(row['query'])
|
489 |
cols[2].write(row['clicks'])
|
490 |
cols[3].write(row['impressions'])
|
|
|
481 |
for col, header in zip(cols, headers):
|
482 |
col.write(f"**{header}**")
|
483 |
|
484 |
+
def truncate_url(url, max_length=50):
|
485 |
+
parsed_url = urllib.parse.urlparse(url)
|
486 |
+
base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"
|
487 |
+
path = parsed_url.path
|
488 |
+
if len(base_url) + len(path) > max_length:
|
489 |
+
return base_url + path[:max_length - len(base_url) - 3] + '...'
|
490 |
+
return base_url + path
|
491 |
+
|
492 |
# Display each row
|
493 |
for index, row in df.iloc[start_idx:end_idx].iterrows():
|
494 |
cols = st.columns([3, 2, 1, 1, 1, 1, 1, 1])
|
495 |
+
cols[0].write(truncate_url(row['page']))
|
496 |
cols[1].write(row['query'])
|
497 |
cols[2].write(row['clicks'])
|
498 |
cols[3].write(row['impressions'])
|