【发布时间】:2017-10-26 02:26:35
【问题描述】:
代码:
doc = Nokogiri::HTML(html)
showings = []
doc.css('.ok-product').each do |showing|
showing_id = showing['data-cart-id'].to_i
price = showing.at_css('.ok-product__price-main').text.gsub(/[\u0440\u0443\u0431.]/, '').strip
showings.push(
id: showing_id,
price: price
)
end
CSV.open("file.csv", "wb") do |csv|
csv << showings
end
我在单元格 A1 的 csv 中获取数据:
{:id=>26999, :price=>"395,00"},"{:id=>26963, :price=>""254,00""}"...
需要将数据分成单元格并删除不必要的符号。
【问题讨论】:
-
细胞叫什么?
-
现在全部在 A1 中。但我需要:A1、B1、A2、B2、A3、B3 ...
-
请阅读“minimal reproducible example”。我们需要证明问题所需的最少输入数据。
html是什么?没有这个,你的问题就没有多大意义。