|
# copied from http://www.cnpp.usda.gov/sites/default/files/usda_food_patterns/EstimatedCalorieNeedsPerDayTable.pdf |
|
s = """2 1,000 1,000 1,000 1,000 1,000 1,000 |
|
3 1,200 1,400 1,400 1,000 1,200 1,400 |
|
4 1,200 1,400 1,600 1,200 1,400 1,400 |
|
5 1,200 1,400 1,600 1,200 1,400 1,600 |
|
6 1,400 1,600 1,800 1,200 1,400 1,600 |
|
7 1,400 1,600 1,800 1,200 1,600 1,800 |
|
8 1,400 1,600 2,000 1,400 1,600 1,800 |
|
9 1,600 1,800 2,000 1,400 1,600 1,800 |
|
10 1,600 1,800 2,200 1,400 1,800 2,000 |
|
11 1,800 2,000 2,200 1,600 1,800 2,000 |
|
12 1,800 2,200 2,400 1,600 2,000 2,200 |
|
13 2,000 2,200 2,600 1,600 2,000 2,200 |
|
14 2,000 2,400 2,800 1,800 2,000 2,400 |
|
15 2,200 2,600 3,000 1,800 2,000 2,400 |
|
16 2,400 2,800 3,200 1,800 2,000 2,400 |
|
17 2,400 2,800 3,200 1,800 2,000 2,400 |
|
18 2,400 2,800 3,200 1,800 2,000 2,400 |
|
19–20 2,600 2,800 3,000 2,000 2,200 2,400 |
|
21–25 2,400 2,800 3,000 2,000 2,200 2,400 |
|
26–30 2,400 2,600 3,000 1,800 2,000 2,400 |
|
31–35 2,400 2,600 3,000 1,800 2,000 2,200 |
|
36–40 2,400 2,600 2,800 1,800 2,000 2,200 |
|
41–45 2,200 2,600 2,800 1,800 2,000 2,200 |
|
46–50 2,200 2,400 2,800 1,800 2,000 2,200 |
|
51–55 2,200 2,400 2,800 1,600 1,800 2,200 |
|
56–60 2,200 2,400 2,600 1,600 1,800 2,200 |
|
61–65 2,000 2,400 2,600 1,600 1,800 2,000 |
|
66–70 2,000 2,200 2,600 1,600 1,800 2,000 |
|
71–75 2,000 2,200 2,600 1,600 1,800 2,000 |
|
76+ 2,000 2,200 2,400 1,600 1,800 2,000""" |
|
|
|
s2 = s.split('\n') |
|
|
|
data = [] |
|
|
|
for line in s2: |
|
age, counts = line.split()[0], line.split()[1:] |
|
if '–' in age: |
|
low, high = age.split('–') |
|
elif age == '2': |
|
low = 0 |
|
high = age |
|
elif '+' in age: |
|
low = age.replace('+', '') |
|
high = 1000 |
|
else: |
|
low, high = age, age |
|
counts = [int(c.replace(',', '')) for c in counts] |
|
data.append([int(low), int(high)] + counts) |
|
|
|
import csv |
|
csv.writer(open('/tmp/calories.csv', 'w')).writerows(data) |