-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize for reading large file? #845
Comments
In my case,just call |
老哥,我也遇到了一样的问题,我一个170m,大约200w行的数据,读取的时候居然占用我接近2g的内存,能优化下不,用那个rows迭代器读的 |
Hi @yqylovy, @ywtGGG , I have improved the streaming reader performance for the rows iterator, memory usage decrease by about 93.7%. Please upgrade to the master branch code. This is a breaking change, the user should be close the stream after using the row's iterator, and close the spreadsheet after opening an existing spreadsheet like this: package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f, err := excelize.OpenFile("Book1.xlsx")
if err != nil {
fmt.Println(err)
return
}
rows, err := f.Rows("Sheet1")
if err != nil {
fmt.Println(err)
return
}
for rows.Next() {
row, err := rows.Columns()
if err != nil {
fmt.Println(err)
}
for _, colCell := range row {
fmt.Print(colCell, "\t")
}
fmt.Println()
}
// Close the stream
if err = rows.Close(); err != nil {
fmt.Println(err)
}
// Close the workbook
if err := f.Close(); err != nil {
fmt.Println(err)
}
} |
@xuri hi,请教下,我发现在
这样的解压调用,使得调用Cols时内存会暴涨,请问是有什么原因这块需要保留原始bytes吗? |
The cell data was stored row by row in the worksheet so that the columns iterator with backtracking required was different from the rows iterator. |
看到也是构建decoder来迭代,具体不同体现在哪呢?如果改成 |
…eaking changes - Close spreadsheet and row's iterator required - New options `WorksheetUnzipMemLimit` have been added - Improve streaming reading performance, memory usage decrease about 93.7%
I have a
30MB
size excel,it contains 50000+ rows。After it unziped, the
xl/worksheets/sheet1.xml
is about330MB
, so while reading it, a lot of memory are used.It's any idea to optimize it?The text was updated successfully, but these errors were encountered: