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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/xls_to_rdf.rb', line 7
def xls_to_rdf(xls, xls_options = nil)
xlsx = Roo::Excelx.new(xls)
xls_options ||= { :sheets => xlsx.sheets}
sheets = xls_options[:sheets]
puts sheets
graph = RDF::Graph.new
wdc = RDF::Vocabulary.new("http://vieslav.pl/csv/0.1/")
sheets.each do |sheet|
puts sheet
xlsx.default_sheet = sheet
table = RDF::Node.new
n=1
= []
xlsx.each_row_streaming(pad_cells: true) do |row|
if n==1 then
row.each do |cell|
value = cell.cell_value
if value != nil then
<< value
end
end
else
bnode = RDF::Node.new
graph << [bnode, RDF.type, wdc[sheet.strip]]
k=0
row.each do |cell|
if cell != nil then
value = cell.cell_value
else
value = nil
end
if [k] != nil then
if value != nil then
graph << [bnode, wdc[[k].strip], value ]
else
graph << [bnode, wdc[[k].strip], ""]
end
end
k = k + 1
end
end
n = n + 1
end
end
graph
end
|