-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbad_data.rb
More file actions
37 lines (31 loc) · 897 Bytes
/
Copy pathbad_data.rb
File metadata and controls
37 lines (31 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
handle = File.open('csv/Ang2010TestsModified.csv', 'r')
inputs = []
good_data = []
total_bad_data = 0
handle.each_line do |line|
is_bad = false
split_elements = line.split('|')
puts line if split_elements.count != 122
split_elements[8..63].each do |s|
s = s.chomp
is_bad = true if s == '' || !(s == '0' || s == '1')
end
split_elements[65..120].each do |s|
s = s.chomp
is_bad = true if s == '' || !(s == '0' || s == '1')
end
total_bad_data += 1 if is_bad
pre_test_responses = split_elements[8..63].collect {|e| e.to_i}
post_test_responses = split_elements[65..120].collect {|e| e.to_i}
pre_total = 0
pre_test_responses.each do |r|
pre_total += 1 if r == 1
end
post_total = 0
post_test_responses.each do |r|
post_total += 1 if r == 1
end
puts line if (post_total - pre_total) < 0 || post_total == 0 || pre_total == 0
end
puts total_bad_data
puts good_data.count