Jump to content
ghostbuster

Python datalogger in google sheets

Recommended Posts

Posted

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)

 

Posted
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?

  • Upvote 1
Posted
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?

Posted
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

  • Like 1
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...