Skip to content

Instantly share code, notes, and snippets.

/1.csv Secret

Created January 19, 2015 04:16
Show Gist options
  • Save anonymous/ba4c34b71cced52cc5cd to your computer and use it in GitHub Desktop.
Save anonymous/ba4c34b71cced52cc5cd to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 44 columns, instead of 4. in line 1.
Handle,Title,Body (HTML),Vendor,Type,Tags,Published,Option1 Name,Option1 Value,Option2 Name,Option2 Value,Option3 Name,Option3 Value,Variant SKU,Variant Grams,Variant Inventory Tracker,Variant Inventory Qty,Variant Inventory Policy,Variant Fulfillment Service,Variant Price,Variant Compare At Price,Variant Requires Shipping,Variant Taxable,Variant Barcode,Image Src,Image Alt Text,Gift Card,Google Shopping / MPN,Google Shopping / Age Group,Google Shopping / Gender,Google Shopping / Google Product Category,SEO Title,SEO Description,Google Shopping / AdWords Grouping,Google Shopping / AdWords Labels,Google Shopping / Condition,Google Shopping / Custom Product,Google Shopping / Custom Label 0,Google Shopping / Custom Label 1,Google Shopping / Custom Label 2,Google Shopping / Custom Label 3,Google Shopping / Custom Label 4,Variant Image,Variant Weight Unit
"example-t-shirt,Example T-Shirt,,Acme,Shirts,mens t-shirt example,TRUE,Title,""Lithograph - Height: 9"""" x Width: 12"""""",,,,,,3629,,1,deny,manual,25,,TRUE,TRUE,,http://cdn.shopify.com/s/images/shopify_shirt.png?e6948ca4d9028f9e734b8202cc472e3b89aae0f3,A black t-shirt with the shopify logo,FALSE,7X8ABC910,Adult,Unisex,Apparel & Accessories > Clothing,Our awesome T-shirt in 70 characters or less.,A great description of your products in 160 characters or less,T-shirts,""cotton, pre-shrunk"",used,FALSE,,,,,,,
","example-t-shirt,,,,,,,Title,Small,,,,,example-shirt-s,200,,1,deny,manual,19.99,24.99,TRUE,TRUE,,,,,,,,,,,,,,,,,,,,,
","example-t-shirt,,,,,,,Title,Medium,,,,,example-shirt-m,200,shopify,1,deny,manual,19.99,24.99,TRUE,TRUE,,,,,,,,,,,,,,,,,,,,,
",",Banana,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
"
require 'csv'
products = CSV.read("product_template.csv", headers: true)
products << []
product = products[products.length-1]
product["Title"] = "Banana"
CSV.open('1.csv', 'w') do |csv_object|
csv_object << products.headers
csv_object << products
end
Handle Title Body (HTML) Vendor Type Tags Published Option1 Name Option1 Value Option2 Name Option2 Value Option3 Name Option3 Value Variant SKU Variant Grams Variant Inventory Tracker Variant Inventory Qty Variant Inventory Policy Variant Fulfillment Service Variant Price Variant Compare At Price Variant Requires Shipping Variant Taxable Variant Barcode Image Src Image Alt Text Gift Card Google Shopping / MPN Google Shopping / Age Group Google Shopping / Gender Google Shopping / Google Product Category SEO Title SEO Description Google Shopping / AdWords Grouping Google Shopping / AdWords Labels Google Shopping / Condition Google Shopping / Custom Product Google Shopping / Custom Label 0 Google Shopping / Custom Label 1 Google Shopping / Custom Label 2 Google Shopping / Custom Label 3 Google Shopping / Custom Label 4 Variant Image Variant Weight Unit
example-t-shirt Example T-Shirt Acme Shirts mens t-shirt example TRUE Title Lithograph - Height: 9" x Width: 12" 3629 1 deny manual 25 TRUE TRUE http://cdn.shopify.com/s/images/shopify_shirt.png?e6948ca4d9028f9e734b8202cc472e3b89aae0f3 A black t-shirt with the shopify logo FALSE 7X8ABC910 Adult Unisex Apparel & Accessories > Clothing Our awesome T-shirt in 70 characters or less. A great description of your products in 160 characters or less T-shirts cotton, pre-shrunk used FALSE
example-t-shirt Title Small example-shirt-s 200 1 deny manual 19.99 24.99 TRUE TRUE
example-t-shirt Title Medium example-shirt-m 200 shopify 1 deny manual 19.99 24.99 TRUE TRUE
Banana
require 'csv'
products = CSV.read("product_template.csv", headers: true)
products << []
product = products[products.length-1]
product["Title"] = "Banana"
CSV.open('2.csv', 'w') do |csv_object|
csv_object << products.headers
products.each do |row_array|
csv_object << row_array
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment