Универсальность и +2 CSV'шки на тест
This commit is contained in:
parent
ab5af21317
commit
17244e37e0
28
import.rb
28
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)
|
||||
|
|
Loading…
Reference in a new issue