osgeo-termbase 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/osgeo/termbase/csv.rb +16 -1
- data/lib/osgeo/termbase/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7bafd03d4736e25d8f71755f850a523e7c35657b5d32f7203ec950e8742188e
|
4
|
+
data.tar.gz: 8f06b100a6a41b7c03ca874da3c12b3eadbbc99d6b35ce91de3246b5655852b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15473ce3109c5ccab7ced943de668cb98c965fcc77f48d3e396053e10242dd6e4012a31c1a93c75bbb2480447d03d88827a4255440115a1143bf50884410e9db
|
7
|
+
data.tar.gz: c23189fbd71141a9b0fcb05f074f1f609a4df7bc38d85ef5c99f88e6f0d0b680a8655790f857b3c7d762ba5f6852d13e5d56c92d87e86598fe068f67dac08781
|
data/Gemfile.lock
CHANGED
data/lib/osgeo/termbase/csv.rb
CHANGED
@@ -21,7 +21,21 @@ class Csv
|
|
21
21
|
def concept_collection
|
22
22
|
collection = ConceptCollection.new
|
23
23
|
|
24
|
-
|
24
|
+
csv_content = File.read(@filename)
|
25
|
+
|
26
|
+
# Google Sheets always uses \n at the last line end, but \r\n for all other line breaks
|
27
|
+
# which causes Ruby's CSV to show this error:
|
28
|
+
# CSV::MalformedCSVError: Unquoted fields do not allow \r or \n
|
29
|
+
# Here we replace the DOS \r\n with Unix \n
|
30
|
+
csv_content = csv_content.gsub(/\r\n/, "\n")
|
31
|
+
|
32
|
+
puts csv_content
|
33
|
+
|
34
|
+
CSV.new(
|
35
|
+
csv_content,
|
36
|
+
liberal_parsing: true,
|
37
|
+
skip_blanks: true
|
38
|
+
).each_with_index do |row, i|
|
25
39
|
next if i < 3
|
26
40
|
term = Term.new(
|
27
41
|
id: i - 2,
|
@@ -35,6 +49,7 @@ class Csv
|
|
35
49
|
language_code: "eng"
|
36
50
|
)
|
37
51
|
|
52
|
+
puts term.to_hash
|
38
53
|
collection.add_term(term)
|
39
54
|
end
|
40
55
|
|