質問編集履歴
4
ソースを変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -74,6 +74,18 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
+
■現在出力される内容
|
78
|
+
|
79
|
+
12345,2019/01/01,23:25
|
80
|
+
|
81
|
+
12345,2019/01/02,19:25
|
82
|
+
|
83
|
+
12345,2019/01/03,21:25
|
84
|
+
|
85
|
+
12345,2019/01/04,23:25
|
86
|
+
|
87
|
+
|
88
|
+
|
77
89
|
|
78
90
|
|
79
91
|
|
@@ -82,6 +94,8 @@
|
|
82
94
|
|
83
95
|
```ここに言語を入力
|
84
96
|
|
97
|
+
Const Path = "C:"
|
98
|
+
|
85
99
|
Const InFile1 = "test1.csv"
|
86
100
|
|
87
101
|
Const InFile2 = "test2.csv"
|
@@ -138,58 +152,72 @@
|
|
138
152
|
|
139
153
|
Set objOutFile = objFso.OpenTextFile(Path & "\" & OutFile1, 2, True)
|
140
154
|
|
141
|
-
|
155
|
+
Do Until objInFile.AtEndOfStream
|
142
|
-
|
156
|
+
|
143
|
-
|
157
|
+
strInFileLine = Split(objInFile.ReadLine, ",")
|
144
|
-
|
158
|
+
|
145
|
-
|
159
|
+
SYA_BG = strInFileLine(0)
|
146
|
-
|
160
|
+
|
147
|
-
|
161
|
+
KINMU_DATE = strInFileLine(1)
|
148
|
-
|
162
|
+
|
149
|
-
|
163
|
+
TIME_1_1 = strInFileLine(2)
|
150
|
-
|
164
|
+
|
151
|
-
|
165
|
+
Do Until objInFile2.AtEndOfStream
|
152
|
-
|
166
|
+
|
153
|
-
|
167
|
+
strInFileLine2 = Split(objInFile2.ReadLine, ",")
|
154
|
-
|
168
|
+
|
155
|
-
|
169
|
+
SYA_BG2 = strInFileLine2(0)
|
156
|
-
|
170
|
+
|
157
|
-
|
171
|
+
KINMU_DATE2 = strInFileLine2(1)
|
158
|
-
|
172
|
+
|
159
|
-
|
173
|
+
NUM(1) = TIME_1_1
|
160
|
-
|
174
|
+
|
161
|
-
|
175
|
+
NUM(2) = strInFileLine2(2)
|
162
|
-
|
176
|
+
|
163
|
-
|
177
|
+
NUM(3) = strInFileLine2(3)
|
164
|
-
|
178
|
+
|
165
|
-
|
179
|
+
NUM(4) = strInFileLine2(4)
|
166
|
-
|
167
|
-
|
180
|
+
|
168
|
-
|
169
|
-
|
181
|
+
IF SYA_BG = SYA_BG2 AND KINMU_DATE = KINMU_DATE2 Then
|
170
|
-
|
182
|
+
|
171
|
-
|
183
|
+
for i = 1 to 4
|
172
|
-
|
184
|
+
|
173
|
-
|
185
|
+
if NUM_MAX < NUM(i) Then
|
174
|
-
|
186
|
+
|
175
|
-
|
187
|
+
NUM_MAX = NUM(i)
|
176
|
-
|
188
|
+
|
177
|
-
|
189
|
+
END IF
|
178
|
-
|
190
|
+
|
179
|
-
|
191
|
+
NEXT
|
180
|
-
|
192
|
+
|
181
|
-
|
193
|
+
END IF
|
182
|
-
|
194
|
+
|
183
|
-
|
195
|
+
TIME_1_1 = NUM_MAX
|
184
|
-
|
185
|
-
'書き込み処理
|
186
|
-
|
187
|
-
objOutFile.WriteLine SYA_BG & "," & KINMU_DATE & "," & TIME_1_1
|
188
|
-
|
189
|
-
Loop
|
190
196
|
|
191
197
|
Loop
|
192
198
|
|
199
|
+
objOutFile.WriteLine SYA_BG & "," & KINMU_DATE & "," & TIME_1_1
|
200
|
+
|
201
|
+
Loop
|
202
|
+
|
203
|
+
objInfile.Close
|
204
|
+
|
205
|
+
objInfile2.Close
|
206
|
+
|
207
|
+
objOutfile.Close
|
208
|
+
|
209
|
+
Set objInfile = Nothing
|
210
|
+
|
211
|
+
Set objInfile2 = Nothing
|
212
|
+
|
213
|
+
Set objOutFile1 = Nothing
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
Set objfso = Nothing
|
218
|
+
|
219
|
+
|
220
|
+
|
193
221
|
```
|
194
222
|
|
195
223
|
|
3
タグの削除、説明文の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
test1.csvの時刻とtest2.csvの3つの時刻の中で(計4つ)の中で一番時刻の遅い値を返すプログラムを書こうとしています。
|
6
6
|
|
7
|
+
test2.csvにデータがなかった場合はそのままtest.1の内容を出力したいです。
|
8
|
+
|
7
9
|
|
8
10
|
|
9
11
|
for文などを使用して添え字やキーなどを作れば可能になりますでしょうか。
|
@@ -180,6 +182,8 @@
|
|
180
182
|
|
181
183
|
TIME_1_1 = NUM_MAX
|
182
184
|
|
185
|
+
'書き込み処理
|
186
|
+
|
183
187
|
objOutFile.WriteLine SYA_BG & "," & KINMU_DATE & "," & TIME_1_1
|
184
188
|
|
185
189
|
Loop
|
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,9 +12,11 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
|
15
|
+
###テストデータ
|
16
|
+
|
16
|
-
|
17
|
+
```
|
18
|
+
|
17
|
-
test1.csvの内容
|
19
|
+
**テストファイル1:test1.csvの内容**
|
18
20
|
|
19
21
|
12345,2019/01/01,17:25
|
20
22
|
|
@@ -24,9 +26,11 @@
|
|
24
26
|
|
25
27
|
12345,2019/01/04,23:25
|
26
28
|
|
27
|
-
|
29
|
+
```
|
30
|
+
|
28
|
-
|
31
|
+
```
|
32
|
+
|
29
|
-
test2.csvの内容
|
33
|
+
**テストファイル2:test2.csvの内容**
|
30
34
|
|
31
35
|
12345,2019/01/01,17:25,23:25,19:25
|
32
36
|
|
@@ -36,9 +40,13 @@
|
|
36
40
|
|
37
41
|
12345,2019/01/04,23:25,21:25,21:25
|
38
42
|
|
39
|
-
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
|
40
|
-
|
47
|
+
```
|
48
|
+
|
41
|
-
OutFile1.csv
|
49
|
+
**出力したい内容:OutFile1.csv**
|
42
50
|
|
43
51
|
12345,2019/01/01,23:25
|
44
52
|
|
@@ -48,7 +56,7 @@
|
|
48
56
|
|
49
57
|
12345,2019/01/04,23:25
|
50
58
|
|
51
|
-
|
59
|
+
```
|
52
60
|
|
53
61
|
|
54
62
|
|
@@ -66,116 +74,128 @@
|
|
66
74
|
|
67
75
|
|
68
76
|
|
77
|
+
|
78
|
+
|
79
|
+
### 作成を試みたソース
|
80
|
+
|
81
|
+
```ここに言語を入力
|
82
|
+
|
83
|
+
Const InFile1 = "test1.csv"
|
84
|
+
|
85
|
+
Const InFile2 = "test2.csv"
|
86
|
+
|
87
|
+
Const OutFile1 = "OutFile1.csv"
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Dim objFso
|
94
|
+
|
95
|
+
Dim T_KEY
|
96
|
+
|
97
|
+
Dim SYA_BG
|
98
|
+
|
99
|
+
Dim KINMU_DATE
|
100
|
+
|
101
|
+
Dim TIME_1_1
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
Dim M_KEY
|
106
|
+
|
107
|
+
Dim SYA_BG2
|
108
|
+
|
109
|
+
Dim KINMU_DATE2
|
110
|
+
|
111
|
+
Dim TIME2_1
|
112
|
+
|
113
|
+
Dim TIME2_2
|
114
|
+
|
115
|
+
Dim TIME2_3
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
Dim count1
|
122
|
+
|
123
|
+
Dim count2
|
124
|
+
|
125
|
+
Dim NUM(4)
|
126
|
+
|
127
|
+
Dim NUM_MAX
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
Set objFso = CreateObject("Scripting.FileSystemObject")
|
132
|
+
|
133
|
+
Set objInFile = objFso.OpenTextFile(Path & "\" & InFile1, 1, False)
|
134
|
+
|
135
|
+
Set objInFile2 = objFso.OpenTextFile(Path & "\" & InFile2, 1, False)
|
136
|
+
|
137
|
+
Set objOutFile = objFso.OpenTextFile(Path & "\" & OutFile1, 2, True)
|
138
|
+
|
139
|
+
Do Until objInFile.AtEndOfStream
|
140
|
+
|
141
|
+
strInFileLine = Split(objInFile.ReadLine, ",")
|
142
|
+
|
143
|
+
SYA_BG = strInFileLine(0)
|
144
|
+
|
145
|
+
KINMU_DATE = strInFileLine(1)
|
146
|
+
|
147
|
+
TIME_1_1 = strInFileLine(2)
|
148
|
+
|
149
|
+
Do Until objInFile2.AtEndOfStream
|
150
|
+
|
151
|
+
strInFileLine2 = Split(objInFile2.ReadLine, ",")
|
152
|
+
|
153
|
+
SYA_BG2 = strInFileLine2(0)
|
154
|
+
|
155
|
+
KINMU_DATE2 = strInFileLine2(1)
|
156
|
+
|
157
|
+
NUM(1) = TIME_1_1
|
158
|
+
|
159
|
+
NUM(2) = strInFileLine2(2)
|
160
|
+
|
161
|
+
NUM(3) = strInFileLine2(3)
|
162
|
+
|
163
|
+
NUM(4) = strInFileLine2(4)
|
164
|
+
|
165
|
+
MsgBox(NUM(1) & "," & NUM(2) & "," & NUM(3) & "," & NUM(4))
|
166
|
+
|
167
|
+
IF SYA_BG = SYA_BG2 AND KINMU_DATE = KINMU_DATE2 Then
|
168
|
+
|
169
|
+
for i = 1 to 4
|
170
|
+
|
171
|
+
if NUM_MAX < NUM(i) Then
|
172
|
+
|
173
|
+
NUM_MAX = NUM(i)
|
174
|
+
|
175
|
+
END IF
|
176
|
+
|
177
|
+
NEXT
|
178
|
+
|
179
|
+
END IF
|
180
|
+
|
181
|
+
TIME_1_1 = NUM_MAX
|
182
|
+
|
183
|
+
objOutFile.WriteLine SYA_BG & "," & KINMU_DATE & "," & TIME_1_1
|
184
|
+
|
185
|
+
Loop
|
186
|
+
|
187
|
+
Loop
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
69
199
|
### 使用言語
|
70
200
|
|
71
201
|
VBS
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
### 作成を試みたソース
|
76
|
-
|
77
|
-
Const InFile1 = "test1.csv"
|
78
|
-
|
79
|
-
Const InFile2 = "test2.csv"
|
80
|
-
|
81
|
-
Const OutFile1 = "OutFile1.csv"
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
Dim objFso
|
88
|
-
|
89
|
-
Dim T_KEY
|
90
|
-
|
91
|
-
Dim SYA_BG
|
92
|
-
|
93
|
-
Dim KINMU_DATE
|
94
|
-
|
95
|
-
Dim TIME_1_1
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
Dim M_KEY
|
100
|
-
|
101
|
-
Dim SYA_BG2
|
102
|
-
|
103
|
-
Dim KINMU_DATE2
|
104
|
-
|
105
|
-
Dim TIME2_1
|
106
|
-
|
107
|
-
Dim TIME2_2
|
108
|
-
|
109
|
-
Dim TIME2_3
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
Dim count1
|
116
|
-
|
117
|
-
Dim count2
|
118
|
-
|
119
|
-
Dim NUM(4)
|
120
|
-
|
121
|
-
Dim NUM_MAX
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
Set objFso = CreateObject("Scripting.FileSystemObject")
|
126
|
-
|
127
|
-
Set objInFile = objFso.OpenTextFile(Path & "\" & InFile1, 1, False)
|
128
|
-
|
129
|
-
Set objInFile2 = objFso.OpenTextFile(Path & "\" & InFile2, 1, False)
|
130
|
-
|
131
|
-
Set objOutFile = objFso.OpenTextFile(Path & "\" & OutFile1, 2, True)
|
132
|
-
|
133
|
-
Do Until objInFile.AtEndOfStream
|
134
|
-
|
135
|
-
strInFileLine = Split(objInFile.ReadLine, ",")
|
136
|
-
|
137
|
-
SYA_BG = strInFileLine(0)
|
138
|
-
|
139
|
-
KINMU_DATE = strInFileLine(1)
|
140
|
-
|
141
|
-
TIME_1_1 = strInFileLine(2)
|
142
|
-
|
143
|
-
Do Until objInFile2.AtEndOfStream
|
144
|
-
|
145
|
-
strInFileLine2 = Split(objInFile2.ReadLine, ",")
|
146
|
-
|
147
|
-
SYA_BG2 = strInFileLine2(0)
|
148
|
-
|
149
|
-
KINMU_DATE2 = strInFileLine2(1)
|
150
|
-
|
151
|
-
NUM(1) = TIME_1_1
|
152
|
-
|
153
|
-
NUM(2) = strInFileLine2(2)
|
154
|
-
|
155
|
-
NUM(3) = strInFileLine2(3)
|
156
|
-
|
157
|
-
NUM(4) = strInFileLine2(4)
|
158
|
-
|
159
|
-
MsgBox(NUM(1) & "," & NUM(2) & "," & NUM(3) & "," & NUM(4))
|
160
|
-
|
161
|
-
IF SYA_BG = SYA_BG2 AND KINMU_DATE = KINMU_DATE2 Then
|
162
|
-
|
163
|
-
for i = 1 to 4
|
164
|
-
|
165
|
-
if NUM_MAX < NUM(i) Then
|
166
|
-
|
167
|
-
NUM_MAX = NUM(i)
|
168
|
-
|
169
|
-
END IF
|
170
|
-
|
171
|
-
NEXT
|
172
|
-
|
173
|
-
END IF
|
174
|
-
|
175
|
-
TIME_1_1 = NUM_MAX
|
176
|
-
|
177
|
-
objOutFile.WriteLine SYA_BG & "," & KINMU_DATE & "," & TIME_1_1
|
178
|
-
|
179
|
-
Loop
|
180
|
-
|
181
|
-
Loop
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
+
【質問内容】
|
2
|
+
|
3
|
+
test1.csvの社員番号と日付とtest2.csvの番号と日付が一致した時だけ
|
4
|
+
|
5
|
+
test1.csvの時刻とtest2.csvの3つの時刻の中で(計4つ)の中で一番時刻の遅い値を返すプログラムを書こうとしています。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
for文などを使用して添え字やキーなどを作れば可能になりますでしょうか。
|
10
|
+
|
1
|
-
|
11
|
+
ご教示ください。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
■テストデータ
|
2
16
|
|
3
17
|
test1.csvの内容
|
4
18
|
|
@@ -36,27 +50,15 @@
|
|
36
50
|
|
37
51
|
|
38
52
|
|
39
|
-
【質問内容】
|
40
|
-
|
41
|
-
test1.csvの社員番号と日付とtest2.csvの番号と日付が一致した時だけ
|
42
|
-
|
43
|
-
test1.csvの時刻とtest2.csvの3つの時刻の中で(計4つ)の中で一番時刻の遅い値を返すプログラムを書こうとしています。
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
for文などを使用して添え字やキーなどを作れば可能になりますでしょうか。
|
48
|
-
|
49
|
-
ご教示ください。
|
50
|
-
|
51
53
|
|
52
54
|
|
53
55
|
|
54
56
|
|
55
57
|
### 発生している問題・エラーメッセージ
|
56
58
|
|
57
|
-
内側のDo Until objInFile2.AtEndOfStreamが終わったあと
|
59
|
+
内側のDo Until objInFile2.AtEndOfStreamが終わったあと
|
58
60
|
|
59
|
-
書き込み処理に移ってしまいます。
|
61
|
+
test1.csvの2行目を比較したいのですが、書き込み処理に移ってしまいます。
|
60
62
|
|
61
63
|
|
62
64
|
|
@@ -64,21 +66,13 @@
|
|
64
66
|
|
65
67
|
|
66
68
|
|
67
|
-
###
|
69
|
+
### 使用言語
|
70
|
+
|
71
|
+
VBS
|
68
72
|
|
69
73
|
|
70
74
|
|
71
|
-
```ここに言語名を入力
|
72
|
-
|
73
|
-
VBS
|
74
|
-
|
75
|
-
VBA
|
76
|
-
|
77
|
-
VB
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
###
|
75
|
+
### 作成を試みたソース
|
82
76
|
|
83
77
|
Const InFile1 = "test1.csv"
|
84
78
|
|