Hello,my code contains a lot of table processing, but I just want to print the final result, why did these contents come out together? How can I remove them?

Hello,my code contains a lot of table processing, but I just want to print the final result, why did these contents come out together? How can I remove them?
Hi @kxy09 ,
Welcome to the Streamlit community forum
Your code snippet shows only one Streamlit Syntax i.e. st.table()
. I presume the above output is probably because of the syntax st.write
Or st.json
, somewhere in your code (not shown in your code snippet).
Commenting those part may help you to hide those output .
Let me know how it goes .
Best
Avra
Thank you for your reply.
Yes, I’m sure I only used one st.table
, have no any st.json
or st.write
. This is all my code.
import bluetooth
import csv
import numpy as np
import pandas as pd
import streamlit as st
st.title('Quick check')
time = st.text_input('Set Time(min=10)', '20', key=int)
time = int(time)
time = time/10
timeint = int(time)
mac=[]
i = 0
for i in range(timeint):
nearby_devices = bluetooth.discover_devices(duration=10,lookup_names=False)
mac.append(nearby_devices)
i=i+1
mac = np.array(mac,dtype=object)
macs=[]
for a in mac:
for b in a:
macs.append(b)
[[macs] for macs in [macs]]
macs = np.array(macs)
macs = np.unique(macs)
macs = macs.T
#print("Found {} devices.".format(len(macs)))
with open("scan.csv", "w", newline='') as f:
writer = csv.writer(f)
writer.writerow(['MAC Address'])
#for addr in macs:
#print(addr)
for scanmac in macs:
writer.writerow([scanmac])
#print("================================================")
with open('scan.csv', 'r') as csvscan:
with open ("list.csv", "r") as csvlist:
reader1 = csv.reader(csvscan)
reader2 = csv.reader(csvlist)
rows1_col_a = [row[0] for row in reader1]
rows2 = [row for row in reader2]
only_b = []
for row in rows2:
if row[2] not in rows1_col_a:
only_b.append(row)
#print(only_b)
title=['Name','ID','MAC Address']
result = pd.DataFrame(columns=title, data=only_b)
#print(result)
st.table(result)
Hi @kxy09,
This line is interpreted as a magic command and implicitly wrapped with st.write()
:
[[macs] for macs in [macs]]
You may want to comment it out. Any time Streamlit sees either a variable or literal value on its own line, it automatically writes that to your app using
st.write
.
Best,
Snehan
It is useful.
Thank you for your time.
Sincerely.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.