Dear Python forum!
I've read quite a bit on how to extract data into a json file but the majority of the documentations found online will only save static data or data you yourself have added by hand.
I have decided to complicate my life a bit and use python to do my project since I had a raspberry pi lying around with a bluetooth I thought might as well....let me explain.
I'm using my Arduino to gather temperature data and via bluetooth send it to my pi.
In order to achieve this first I have to somehow save whatever numbers I'm getting in the while function. My initial idea was to just save it as a txt file like this:
After a bit of research I found out saving it to CSV or JSON would be a lot more desirable but no documentation I've read so far uses the variables as inputs into the JSON or CSV file. I've done quite a few attempts but I was unsuccessful.
As I am new to this and got nobody else to ask I'd appreciate any help.
Sorry for an entry level question and thanks if you have read through it.
Sincerely,
Nyanpasu
I've read quite a bit on how to extract data into a json file but the majority of the documentations found online will only save static data or data you yourself have added by hand.
I have decided to complicate my life a bit and use python to do my project since I had a raspberry pi lying around with a bluetooth I thought might as well....let me explain.
I'm using my Arduino to gather temperature data and via bluetooth send it to my pi.
#! /usr/bin/python import serial import datetime ser = serial.Serial('/dev/rfcomm0' , 9600) print(ser.name) print("Connected") while True: now = datetime.datetime.now() ser_bytes = ser.readline() print (now.strftime("%Y-%m-%d %H:%M:%S, ")), ser_bytesEventually I'd like to load this into a database and make a plot that is visible on a website where the x is the time and y is the temperature.
In order to achieve this first I have to somehow save whatever numbers I'm getting in the while function. My initial idea was to just save it as a txt file like this:
nohup python -u temp.py &This would work but eventually the file would get too big and probably not the nicest way to solve this problem, so I have to somehow limit the number of lines allowed in the database.
After a bit of research I found out saving it to CSV or JSON would be a lot more desirable but no documentation I've read so far uses the variables as inputs into the JSON or CSV file. I've done quite a few attempts but I was unsuccessful.
As I am new to this and got nobody else to ask I'd appreciate any help.
Sorry for an entry level question and thanks if you have read through it.
Sincerely,
Nyanpasu