回答編集履歴
1
jsonのサンプルと、pythonのソースを追加しました。
answer
CHANGED
@@ -1,2 +1,95 @@
|
|
1
1
|
その json データでは、 issues キーが重複するため、どんどん上書きされていって最後の issues のみ残ってしまいます。
|
2
|
-
そこを改良してください。
|
2
|
+
そこを改良してください。
|
3
|
+
|
4
|
+
ここから追記です。
|
5
|
+
|
6
|
+
filename : tera.json
|
7
|
+
```json
|
8
|
+
{
|
9
|
+
"expand": "schemanames",
|
10
|
+
"startAt": 0,
|
11
|
+
"maxResults": 100,
|
12
|
+
"total": 150,
|
13
|
+
"issues": [
|
14
|
+
{
|
15
|
+
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
|
16
|
+
"id": "111111",
|
17
|
+
"self": "https://sample.jp//api/2/project/111111'",
|
18
|
+
"key": "911",
|
19
|
+
"fields": {
|
20
|
+
"parent": {
|
21
|
+
"id": "54321",
|
22
|
+
"key": "11",
|
23
|
+
"self": "https://sample.jp//api/2/project/11112'"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
|
29
|
+
"id": "111112",
|
30
|
+
"self": "https://sample.jp//api/2/project/111111'",
|
31
|
+
"key": "912",
|
32
|
+
"fields": {
|
33
|
+
"parent": {
|
34
|
+
"id": "54322",
|
35
|
+
"key": "12",
|
36
|
+
"self": "https://sample.jp//api/2/project/11112'"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
],
|
41
|
+
"issues2": [
|
42
|
+
{
|
43
|
+
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
|
44
|
+
"id": "222222",
|
45
|
+
"self": "https://sample.jp//api/2/project/222222'",
|
46
|
+
"key": "912",
|
47
|
+
"fields": {
|
48
|
+
"parent": {
|
49
|
+
"id": "64320",
|
50
|
+
"key": "21",
|
51
|
+
"self": "https://sample.jp//api/2/project/11142'"
|
52
|
+
}
|
53
|
+
}
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
|
57
|
+
"id": "3333",
|
58
|
+
"self": "https://sample.jp//api/2/project/222222'",
|
59
|
+
"key": "913",
|
60
|
+
"fields": {
|
61
|
+
"parent": {
|
62
|
+
"id": "54321",
|
63
|
+
"key": "22",
|
64
|
+
"self": "https://sample.jp//api/2/project/11142'"
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
]
|
70
|
+
}
|
71
|
+
|
72
|
+
```
|
73
|
+
|
74
|
+
こんな構造のjsonだったとしたら
|
75
|
+
|
76
|
+
```python
|
77
|
+
import pandas as pd
|
78
|
+
from pandas.io.json import json_normalize
|
79
|
+
import openpyxl
|
80
|
+
|
81
|
+
f= open("tera.json", "r")
|
82
|
+
data = json.load(f)
|
83
|
+
|
84
|
+
with pd.ExcelWriter("test.xlsx") as writer:
|
85
|
+
for v in data:
|
86
|
+
if "issues" in v:
|
87
|
+
r = json_normalize(data[v])
|
88
|
+
r.to_excel(writer, sheet_name=v)
|
89
|
+
```
|
90
|
+
|
91
|
+
これで大体やりたいことはできるかと思います。
|
92
|
+
|
93
|
+
jsonを修正したところとしては、issues のキー名を重複しないように変更したことです。
|
94
|
+
もっと構造を変えてもよければ、issues自体をリスト化することです。
|
95
|
+
そうするともう少しスマートになるかと。
|