How to not show the content of the unprocessed table?

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?


QQ截图20211225191736

Hi @kxy09 ,

Welcome to the Streamlit community forum :partying_face::balloon:

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)

1 Like

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. :point_up: 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, :balloon:
Snehan

2 Likes

It is useful. :grinning_face_with_smiling_eyes:
Thank you for your time.
Sincerely.