forked from Stefhu67/camera_toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_data.py
30 lines (26 loc) · 887 Bytes
/
export_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pandas as pd
from tinydb import TinyDB, where
import matplotlib.pyplot as plt
from datetime import datetime
import glob
def export_experiment_csv():
for name in glob.glob('*.json'):
db_path = name
db = TinyDB(db_path)
df = pd.read_json(db_path, lines = False, typ = "series")
df = pd.DataFrame.from_dict( df["_default"], orient = "index" )
df = df.explode("value")
filename = name.split(".")[0]
df.to_csv(filename+".csv")
plot_arduino(df, filename)
def plot_arduino(df, filename):
arduino_df = df.loc[df["type"] == "arduino"]
#arduino_df.to_csv("./arduino_data.csv")
x = []
y = []
for index, row in arduino_df.iterrows():
x.append( float(row["timestamp"]) )
y.append( float(row["value"][0]) )
plt.plot(x,y)
plt.savefig(filename+".png")
export_experiment_csv()