Currently, I am using the Piyolog App for raising 0-year-old children. With this app, you can export the content entered on your smartphone as text. I wondered if I could do something with this data.
Use the information from the Piyolog app to visualize the growth of your baby based on objective data, and look at the graph saying "Oh! Growing up!" To increase motivation for childcare. (Although I feel that the number of people who get motivated by looking at the graph is limited)
Piyo log → GAS → Raspberry pi (Shell + Python) → LINE When you export from Piyo log and send it to Gmail, the graphed result will be automatically sent to LINE.
The text data (one day's worth) exported from the Piyo log looks like this.
piyolog.txt
[Piyo Log] May 2020
2020/5/1(Money)
Child's name(0 years xx months xx days)
02:25 get up(3 hours 15 minutes)
02:30 pee
02:50 sleep
03:50 pee
05:40 get up(2 hours 50 minutes)
05:55 milk 130ml
~ Abbreviation ~
22:45 sleep
Breast milk total left 0 minutes/Right 0 minutes
Milk total 9 times 840ml
Total sleep 13 hours 40 minutes
Pee total 9 times
Poop total 1 time
Make a simple graph so that you can visually understand the trends 1 to 3.
The code is excerpted only for the main part.
python
#Piyolog milk,List only items such as poop
def get_piyolog_all_items(texts):
days = []
all_items = []
for month in texts:
#Split text with line breaks
lines = month.splitlines()
#Make it a numpy array
array = np.array(lines)
for index, item in enumerate(array):
#Get date
if item == "----------" and index < len(array) - 1:
day = array[index + 1]
days.append(day)
#Ignore blank lines & time the item you want to record(hh:mm)Judgment by
if item != "" and check_item(item):
#Store date and time and items in an array
day_items = [day] + item.split()
all_items.append(day_items)
return all_items
get_each_day_milks
def get_each_day_milks(select, days, all_items):
for item in all_items:
#Extract the elements of milk
if item[2] == "milk":
milk = item[3]
milk = int(milk.replace("ml", ""))
all_milks.append([item[0], item[1], milk])
for day in days:
for array_milk in all_milks:
#Maximum amount of milk per day
if day == array_milk[0] and day_milk_max < array_milk[2]:
#Save maximum value once
tmp_max_milk = array_milk
#Update the maximum value for the day
day_milk_max = array_milk[2]
#Total amount of milk per day
if day == array_milk[0]:
day_milk_sum += array_milk[2]
#0 is not recorded
if tmp_max_milk != 0:
#Add to maximum milk list
max_milks.append(tmp_max_milk)
#Add to total milk list
sum_milks.append([day, "", day_milk_sum])
#Add to cumulative milk list
all_milk_acc += day_milk_sum
acc_milks.append([day, "", all_milk_acc])
#Initialization
day_milk_max = 0
day_milk_sum = 0
# return
if select == "max":
return max_milks
elif select == "sum":
return sum_milks
elif select == "acc":
return acc_milks
else:
return "error!"
python
#Send images to LINE
def send_picture_to_line(PICTURE_PATH):
url = LINE_URL
token = LINE_TOKEN
headers = {"Authorization": "Bearer " + token}
#message
payload = {"message": "send picture"}
#image
files = {"imageFile": open(PICTURE_PATH, "rb")}
# post
requests.post(url, data=payload, headers=headers, files=files)
You can see that the amount of milk you drink increases significantly during the newborn period (0 to 30 days after birth)! Growing up!
After the newborn period, I drink 1000ml almost every day. The reason why the last day has dropped sharply is because it was the data in the middle of the day.
Naturally, it is rising. It may be a natural graph, but moms and dads can feel relieved just by confirming that it is steadily rising. If the slope becomes gentle, are you feeling sick? You may notice.
Growth may be seen by visualizing changes in the total sleep time and the average value of sleep time. I am drinking 60000ml = 60000g 80 days after birth. I gained 3500g for my child, so Most of 60000-3500 = 56500g seems to have been peeing and pooping.
Recommended Posts