ghostbuster Posted October 18, 2023 Report Share Posted October 18, 2023 Buna ziua, ma poate ajuta cineva cu codul acesta? Vreau ca la fiecare secunda sa imi scrie leq_level in fiecare celula in parte din coloana A de exemplu, in momentul acesta am reusit sa il fac sa puna decibeli in aceasi celula la 1 secunda distanta. import nsrt_mk3_dev import gspread import time nsrt = nsrt_mk3_dev.NsrtMk3Dev('COM11') model = nsrt.read_model() sa = gspread.service_account() sh = sa.open("DevSchiu") wks = sh.worksheet("Folha1") while(1): leq_level = nsrt.read_leq() weighting = nsrt.read_weighting() weighted_level = nsrt.read_level() wks.update('a2', leq_level ) print(f'DecibelLevel: {leq_level:0.2f} dB, {weighting} value: {weighted_level:0.2f}') time.sleep(1) Quote Link to comment Share on other sites More sharing options...
pr00f Posted October 18, 2023 Report Share Posted October 18, 2023 row_num = 1 # primul rand de unde vrei sa inceapa while True: leq_level = nsrt.read_leq() weighting = nsrt.read_weighting() weighted_level = nsrt.read_level() wks.update(f'a{row_num}', leq_level ) print(f'DecibelLevel: {leq_level:0.2f} dB, {weighting} value: {weighted_level:0.2f}') time.sleep(1) row_num += 1 incrementarea randului? 1 Quote Link to comment Share on other sites More sharing options...
ghostbuster Posted October 18, 2023 Author Report Share Posted October 18, 2023 7 minutes ago, pr00f said: row_num = 1 # primul rand de unde vrei sa inceapa while True: leq_level = nsrt.read_leq() weighting = nsrt.read_weighting() weighted_level = nsrt.read_level() wks.update(f'a{row_num}', leq_level ) print(f'DecibelLevel: {leq_level:0.2f} dB, {weighting} value: {weighted_level:0.2f}') time.sleep(1) row_num += 1 incrementarea randului? Multumesc frumos, si ca sa pun si data/ hora pe coloana 2? Quote Link to comment Share on other sites More sharing options...
pr00f Posted October 18, 2023 Report Share Posted October 18, 2023 from datetime import datetime ... while True: ... wks.update(f'A{row_num}', leq_level) wks.update(f'B{row_num}', datetime.now().strftime('%Y-%m-%d %H:%M:%S')) ... te joci cu formatul de la datetime cum ai nevoie 1 1 Quote Link to comment Share on other sites More sharing options...