xsv 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/xsv/sheet.rb +14 -4
- data/lib/xsv/sheet_bounds_handler.rb +2 -2
- data/lib/xsv/version.rb +1 -1
- data/lib/xsv/workbook.rb +1 -9
- 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: f5a4e91e03098400d7c83734fe68128418de719c3c9c0dc95e2e31e5beca9f90
|
|
4
|
+
data.tar.gz: 78488c6161efcec8e503403b35181b7efe827fb8a67cf8f579d06b444dc50a8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e43aa9c8ace8fee462cfaa09a8af785c7522c1ce31810523f5e4d498e3239b8c8e096ce11f638cb31561fc37ed0f7ce9d65d992dbaff23876c1f3fa68d9b44fb
|
|
7
|
+
data.tar.gz: 812911282e79f7737a27410b71bbe92fc941af181ae7e38c774ced448dcf88643a194e294f9b71862b8cb2eba41b01e0ee755fd4800bcae8ea4a025eefa78a9d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Xsv Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.7 - 2020-03-05
|
|
4
|
+
|
|
5
|
+
Reduce retained memory, making Xsv the definite performance king among the
|
|
6
|
+
Ruby Excel parsing gems.
|
|
7
|
+
|
|
8
|
+
## 0.3.6 - 2020-03-05
|
|
9
|
+
|
|
10
|
+
Reduce memory usage
|
|
11
|
+
|
|
3
12
|
## 0.3.5 - 2020-03-02
|
|
4
13
|
|
|
5
14
|
Fix a Gemfile small Gemfile issue that broke the 0.3.3 and 0.3.4 releases
|
data/lib/xsv/sheet.rb
CHANGED
|
@@ -28,10 +28,12 @@ module Xsv
|
|
|
28
28
|
# There is no need to create Sheets from application code.
|
|
29
29
|
#
|
|
30
30
|
# @param workbook [Workbook] The Workbook with shared data such as shared strings and styles
|
|
31
|
-
# @param io [IO] A handle to an open worksheet XML file
|
|
32
|
-
|
|
31
|
+
# @param io [IO] A handle to an open worksheet XML file
|
|
32
|
+
# @param size [Number] size of the XML file
|
|
33
|
+
def initialize(workbook, io, size)
|
|
33
34
|
@workbook = workbook
|
|
34
35
|
@io = io
|
|
36
|
+
@size = size
|
|
35
37
|
@headers = []
|
|
36
38
|
@mode = :array
|
|
37
39
|
@row_skip = 0
|
|
@@ -46,11 +48,19 @@ module Xsv
|
|
|
46
48
|
|
|
47
49
|
# Iterate over rows, returning either hashes or arrays based on the current mode.
|
|
48
50
|
def each_row(&block)
|
|
49
|
-
@io.rewind
|
|
51
|
+
@io.rewind
|
|
50
52
|
|
|
51
53
|
handler = SheetRowsHandler.new(@mode, empty_row, @workbook, @row_skip, @last_row, &block)
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
# For smaller sheets, memory performance is a lot better if Ox is
|
|
56
|
+
# handed a string. For larger sheets this leads to awful performance.
|
|
57
|
+
# This is probably caused by either something in SheetRowsHandler or
|
|
58
|
+
# the interaction between Zip::InputStream and Ox
|
|
59
|
+
if @size > 100_000_000
|
|
60
|
+
Ox.sax_parse(handler, @io)
|
|
61
|
+
else
|
|
62
|
+
Ox.sax_parse(handler, @io.read)
|
|
63
|
+
end
|
|
54
64
|
|
|
55
65
|
true
|
|
56
66
|
end
|
data/lib/xsv/version.rb
CHANGED
data/lib/xsv/workbook.rb
CHANGED
|
@@ -80,15 +80,7 @@ module Xsv
|
|
|
80
80
|
@zip.glob("xl/worksheets/sheet*.xml").sort do |a, b|
|
|
81
81
|
a.name[/\d+/].to_i <=> b.name[/\d+/].to_i
|
|
82
82
|
end.each do |entry|
|
|
83
|
-
|
|
84
|
-
# handed a string. For larger sheets this leads to awful performance.
|
|
85
|
-
# This is probably caused by either something in SheetRowsHandler or
|
|
86
|
-
# the interaction between Zip::InputStream and Ox
|
|
87
|
-
if entry.size > 100_000_000
|
|
88
|
-
@sheets << Xsv::Sheet.new(self, entry.get_input_stream)
|
|
89
|
-
else
|
|
90
|
-
@sheets << Xsv::Sheet.new(self, entry.get_input_stream.read)
|
|
91
|
-
end
|
|
83
|
+
@sheets << Xsv::Sheet.new(self, entry.get_input_stream, entry.size)
|
|
92
84
|
end
|
|
93
85
|
end
|
|
94
86
|
end
|