Created
December 1, 2014 06:34
-
-
Save wookay/f9d935ed57aaaf4825ce to your computer and use it in GitHub Desktop.
journal.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#-- coding: utf-8 -- | |
# textutil -convert txt Journal*.docx | |
import numpy as np | |
import pandas as pd | |
def regul(s): | |
b = s.split(":")[1].strip() | |
if len(b) > 0: | |
return [float(x) for x in b.split(",")] | |
else: | |
return [] | |
def get_df(): | |
h = {} | |
for x in range(1,28+1): | |
week = 'Journal%02d.txt' % x | |
f = open(week, 'r') | |
prev1 = '' | |
prev2 = '' | |
d = {} | |
for line in f.readlines(): | |
if line.startswith('- 끝:'): | |
morning = regul(prev1) | |
night = regul(line) | |
mmean = np.mean(morning) | |
nmean = np.mean(night) | |
day = str('Journal-%02d ' % x) + prev2.split(" -")[0].strip() | |
d[day] = [mmean, nmean] | |
prev2 = prev1 | |
prev1 = line | |
f.close() | |
h.update(d) | |
return pd.DataFrame(h) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment