質問編集履歴

1

質問対象コードを追加しました。

2020/05/03 11:13

投稿

amaturePy
amaturePy

スコア131

test CHANGED
File without changes
test CHANGED
@@ -24,17 +24,51 @@
24
24
 
25
25
 
26
26
 
27
- def _id_choice(fr,f2,ind_row,ind_row2):⇦下のコードからcsvデータを引数で取得
27
+ def _id_choice(fr,f2,ind_row,ind_row2):
28
28
 
29
- len0 = 0 ⇦この変数が分からない
29
+ len0 = 0
30
30
 
31
- for row in fr:
31
+ for row in fr:
32
32
 
33
- if len0>0:
33
+ if len0>0:
34
34
 
35
- a, b = row[0], row[ind_row]
35
+ a, b = row[0], row[ind_row]
36
36
 
37
- b1 = b.split("/")
37
+ b1 = b.split("/")
38
+
39
+ for x in b1:
40
+
41
+ if x!="":
42
+
43
+ row_new = _replace(row[ind_row2])
44
+
45
+ row_new1 = row_new.split("/") ### check later! ###
46
+
47
+ if len(row_new1)>1:
48
+
49
+ if len(row_new1)!=len(b1):
50
+
51
+ print("different numbers of items at line %s" % len0)
52
+
53
+ c = row_new1[b1.index(x)] # check later
54
+
55
+ f2.write("%s/%s\t%s\r\n" % (x,a,c)) # check later
56
+
57
+ else:
58
+
59
+ c = row_new1[b1.index(x)]
60
+
61
+ f2.write("%s/%s\t%s\r\n" % (x,a,c))
62
+
63
+ else:
64
+
65
+ f2.write("%s/%s\t%s\r\n" % (x,a,row_new))
66
+
67
+ len0 += 1
68
+
69
+ return len0
70
+
71
+
38
72
 
39
73
  ```
40
74