csvkit 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/csvkit/csvkit.rb +8 -1
- data/lib/csvkit/version.rb +1 -1
- metadata +1 -1
data/lib/csvkit/csvkit.rb
CHANGED
@@ -20,7 +20,10 @@ class CSVKit
|
|
20
20
|
doc.xpath('//table//tr').each do |row|
|
21
21
|
tsv_row = []
|
22
22
|
row.xpath('td | th').each do |cell|
|
23
|
-
|
23
|
+
repeat = header_with_colspan?(cell) ? cell['colspan'].to_i : 1
|
24
|
+
repeat.times do
|
25
|
+
tsv_row << clean_cell_string(cell.text)
|
26
|
+
end
|
24
27
|
end
|
25
28
|
tsv << tsv_row
|
26
29
|
end
|
@@ -43,6 +46,10 @@ class CSVKit
|
|
43
46
|
is_numeric?(cell_string) ? cell_string.to_b : cell_string.strip
|
44
47
|
end
|
45
48
|
|
49
|
+
def header_with_colspan?(cell)
|
50
|
+
'th' == cell.name && cell.key?('colspan')
|
51
|
+
end
|
52
|
+
|
46
53
|
def is_numeric?(string)
|
47
54
|
return true if self =~ /^\d+$/
|
48
55
|
true if Float(self) rescue false
|
data/lib/csvkit/version.rb
CHANGED