[英]NoMemoryError: failed to allocate memory
I have an xlsx file with a lot of data, and I have this script to insert data from the xlsx file into my own database: 我有一个包含大量数据的xlsx文件,并且我有此脚本可以将xlsx文件中的数据插入到我自己的数据库中:
file = 'lib/assets/sicepatfull.xlsx'
xlsx = Roo::Spreadsheet.open(file)
sheet = xlsx.sheet(0)
attrs = sheet.row(1)
data = sheet.parse(header_search: attrs).map do |d|
d.map {|k, v| [k.parameterize.underscore.to_sym, v] }.to_h.except :id
end
Courier.create!(data)
The command is cancelled after the attrs
, and the result is: NoMemoryError: failed to allocate memory
. 在
attrs
之后取消该命令,结果是: NoMemoryError: failed to allocate memory
。
How do I fix it? 我如何解决它?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.