teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

一部関数を追加しました。

2020/05/05 01:10

投稿

amaturePy
amaturePy

スコア131

title CHANGED
File without changes
body CHANGED
@@ -6,7 +6,6 @@
6
6
  len2 = _id_choice(fr0,f2,6,7) ⇦ここの6、7引数
7
7
  len3 = _id_choice(fr1,f2,3,4) ⇦3、4の引数
8
8
  ```
9
-
10
9
  ```
11
10
  import codecs
12
11
  import csv
@@ -41,6 +40,22 @@
41
40
  ```
42
41
  _function.py
43
42
 
43
+ def _load_file(file0,file1):
44
+ f0 = open(file0, "r", encoding="utf-8", errors="", newline="")
45
+ f1 = open(file1, "r", encoding="utf-8", errors="", newline="")
46
+ fr0 = csv.reader(f0, delimiter=",", doublequote=True, lineterminator="\r\n", quotechar='"', skipinitialspace=True)
47
+ fr1 = csv.reader(f1, delimiter=",", doublequote=True, lineterminator="\r\n", quotechar='"', skipinitialspace=True)
48
+ return f0, f1, fr0, fr1
49
+
50
+ ####################################
51
+ def _replace(x):
52
+ y = x.replace("\n", " ")
53
+ y = y.replace("\r", " ")
54
+ y = y.replace("\t", " ") # error when input data have tabs
55
+ y = y.replace("\v", " ") # vertical tab
56
+ y = y.replace('"', ' ')
57
+ return y
58
+
44
59
  def _id_choice(fr,f2,ind_row,ind_row2):
45
60
  len0 = 0
46
61
  for row in fr:

1

CSVのカラム情報を追加しました。

2020/05/05 01:10

投稿

amaturePy
amaturePy

スコア131

title CHANGED
File without changes
body CHANGED
@@ -65,4 +65,8 @@
65
65
  f2.write("%s/%s\t%s\r\n" % (x,a,row_new))
66
66
  len0 += 1
67
67
  return len0
68
+ ```
69
+ ```
70
+ csv(どちらのcsvも同じ構成になります)
71
+ ID/フォルダーID/コンポーネント名/メッセージ/遷移元ID/選択肢/遷移人数/遷移率/CV/OID
68
72
  ```