我想我想创建一个像这样的.json:
[{"county": "Fulton County", "weighted_graduation_rate": 91,
"geography": // A bunch of geoJson here,
"children": [{"school_name":"North Fulton", "graduation_rate": 88}
{"school_name":"South Fulton", "graduation_rate": 92}
]
}{
"county": "Cobb County", "weighted_graduation_rate": 85,
"geography": // A bunch of geoJson here,
"children": [{"school_name":"North Cobb", "graduation_rate": 88}
{"school_name":"South Cobb", "graduation_rate": 78}
]
}]
或换句话说:
/ North Fulton, graduation rate 88
Fulton County School System, weighted graduation rate 91, geography
/ \South Fulton, graduation rate 92
counties
\ / North Cobb, graduation rate 88
Cobb County School System, weighted graduation rate 85, geography
\South Cobb, graduation rate 78
原始csv:
county, school_name, graduation_rate
Fulton County, North Fulton, 88
Fulton County, South Fulton, 92
Fulton County, mean all schools, 91
Cobb County, North Cobb, 78
Cobb County, South Cobb, 88
Cobb County, mean all schools, 85
这就是问题:
如果我按县筑巢,每个县都有三个孩子:北校,南校和县平均分。
所以我不得不选择更复杂的东西,但我不知道是什么。
每个县都必须拥有系统地理位置和一个拥有子学校的阵列。
我无法删除“所有学校”的数据,因为它是加权的。没有每所学校的重量。所以我不得不呼吁。我以后无法计算。
有没有办法通过巢来解决这个问题?还是需要去递归?