質問編集履歴
2
q
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,63 @@
|
|
1
|
+
ほそく
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```ここに言語を入力
|
6
|
+
|
7
|
+
#list リスト型の場合
|
8
|
+
|
9
|
+
if isinstance(variable_field,list) == True:
|
10
|
+
|
11
|
+
print("csv-outpiut:list ",type(variable_field))
|
12
|
+
|
13
|
+
writer.writerow(fixed_field + variable_field) # 固定項目+可変項目
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
#dict 辞書型の場合
|
18
|
+
|
19
|
+
elif isinstance(variable_field,dict) == True:
|
20
|
+
|
21
|
+
print("csv-outpiut:dict ",type(variable_field))
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
lst = []
|
26
|
+
|
27
|
+
for e in variable_field.items():
|
28
|
+
|
29
|
+
lst.extend(e)
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
print("lst :",lst)
|
34
|
+
|
35
|
+
writer.writerow(fixed_field + lst) # 固定項目+可変項目
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
#タプル型の場合
|
40
|
+
|
41
|
+
elif isinstance(variable_field,tuple) == True:
|
42
|
+
|
43
|
+
print("csv-outpiut:tuple ",type(variable_field))
|
44
|
+
|
45
|
+
listed_var = list(variable_field)
|
46
|
+
|
47
|
+
writer.writerow(fixed_field + listed_var) # 固定項目+可変項目
|
48
|
+
|
49
|
+
else:
|
50
|
+
|
51
|
+
print("csv-outpiut:other ------------------e-r-r-o-r-e-r-r-o-r-e-r-",type(variable_field))
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
1
61
|
おせわになります。初心者です。
|
2
62
|
|
3
63
|
辞書型データを並び順は同じで配列型リスト型に変換するには
|
1
s
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,3 +33,9 @@
|
|
33
33
|
|
34
34
|
|
35
35
|
よろしくお願いします
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
参考サイト
|
40
|
+
|
41
|
+
http://ututel.blog121.fc2.com/blog-entry-45.html
|