0
배열에서 스프레드 시트를 만들려고합니다. 내가 행의 데이터를 하나의 거대한 행으로 끝낼하지 않도록배열의 X 문자열 양당 새로운 CSV 행을 만드는 방법
#Loop through each .olpOffer (product listing) and gather content from various elements
parse_page.css('.olpOffer').each do |a|
if a.css('.olpSellerName img').empty?
seller = a.css('.olpSellerName').text.strip
else
seller = a.css('.olpSellerName img').attr('alt').value
end
offer_price = a.css('.olpOfferPrice').text.strip
prime = a.css('.supersaver').text.strip
shipping_info = a.css('.olpShippingInfo').text.strip.squeeze(" ").gsub!(/(\n)/, '')
condition = a.css('.olpCondition').text.strip
fba = "FBA" unless a.css('.olpBadge').empty?
#Push data from each product listing into array
arr.push(seller,offer_price,prime,shipping_info,condition,fba)
end
#Need to make each product listing's data begin in new row [HELP!!]
CSV.open("file.csv", "wb") do |csv|
csv << ["Seller", "Price", "Prime", "Shipping", "Condition", "FBA"]
end
end
내가 배열이 "FBA"
열 이후에 쓰기 작업을 수행하는 행을 재설정해야 2.
나는 알아낼 수 없습니다 각 문자열을 특정 열 머리글과 상관시키는 방법을 설명합니다. 배열을 사용하지 않아야합니까?
에 의해 항상 나눌 문자열의 일부 주어진 양을 가지고 배열을 =? – mudasobwa