From 17244e37e0ba13272125b5daf072df4e016ba33a Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Mon, 9 Jan 2017 18:06:39 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BD=D0=B8=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=B8=20+2?= =?UTF-8?q?=20CSV'=D1=88=D0=BA=D0=B8=20=D0=BD=D0=B0=20=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- import.rb | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/import.rb b/import.rb index 53ad978..e7d4169 100644 --- a/import.rb +++ b/import.rb @@ -30,7 +30,7 @@ def parse_file(input, index_brand, index_name, index_code, index_cross) brand = row[index_brand] name = row[index_name] code = row[index_code] - cross = row[index_cross].split(',') + cross = row[index_cross].split(/[,;]/) brand_id = get_brand_id(brand) part_id = insert_part(name, brand_id, '', code) cross.each do |item| @@ -47,12 +47,30 @@ end input = File.open("ИверсАвто.csv") input.readline # пропускаем шапку CSV -parse_file(input, 0, 2, 5, 4) +parse_file(input, 0, 2, 5, 4) # index_brand, index_name, index_code, index_cross input.close unless input.nil? input = File.open("Автооптима Остатки 14.01.csv") -input.readline # пропускаем шапку CSV -input.readline -input.readline +3.times do + input.readline # пропускаем шапку CSV +end parse_file(input, 7, 8, 2, 3) input.close unless input.nil? + +input = File.open("Masuma.csv") +6.times do + input.readline # пропускаем шапку CSV +end +parse_file(input, 0, 4, 3, 2) + +input = File.open("PriceTiss.csv") +9.times do + input.readline # пропускаем шапку CSV +end +parse_file(input, 1, 2, 3, 5) + +input = File.open("Rossko.csv") +1.times do + input.readline # пропускаем шапку CSV +end +parse_file(input, 1, 0, 11)