Created
June 7, 2011 14:46
-
-
Save XULRunner42/1012389 to your computer and use it in GitHub Desktop.
Generic TSV -> Amazon Mapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package trans | |
import ( | |
dbi "github.com/thomaslee/go-dbi" | |
_ "github.com/thomaslee/go-dbd-sqlite" | |
vector "container/vector" | |
"fmt" | |
) | |
type MagentoListing struct { | |
} | |
func (listing *BasicListing) String() string { | |
s := | |
return s | |
} | |
func NpToMagento () { | |
npconn, err := dbi.Connect("sqlite://./np.sqlite") | |
if err != nil { | |
fmt.Printf("error: connecting to np.sqlite: %s\n", err.String()) | |
return | |
} | |
defer npconn.Close() | |
magconn, err := dbi.Connect("sqlite://./magento.sqlite") | |
if err != nil { | |
fmt.Printf("error: connecting to magento.sqlite: %s\n", err.String()) | |
return | |
} | |
rs, err := npconn.Query(``) | |
if err != nil { | |
fmt.Printf("error: reading from np.sqlite: %s\n", err.String()) | |
return | |
} | |
defer rs.Close() | |
vec := new(vector.Vector) | |
for rs.Next() { | |
var minimum Magento = new(Magento) | |
err = rs.Scan(&minimum.ProductName, &minimum.ModelNumber, | |
&minimum.List, &minimum.Cost) | |
if err != nil { | |
fmt.Printf("error: %s\n", err.String()) | |
} | |
item := | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package trans | |
import ( | |
dbi "github.com/thomaslee/go-dbi" | |
_ "github.com/thomaslee/go-dbd-sqlite" | |
vector "container/vector" | |
"fmt" | |
) | |
type BasicListing struct { | |
ProductName string | |
ModelNumber string | |
List string | |
Cost string | |
} | |
func (listing *BasicListing) String() string { | |
s := fmt.Sprintf(`{ product_name: '%s', | |
model_number: '%s', | |
list: '%s', | |
cost: '%s'} | |
`, listing.ProductName, listing.ModelNumber, listing.List, | |
listing.Cost) | |
return s | |
} | |
func NpToAmazon () { | |
npconn, err := dbi.Connect("sqlite://./np.sqlite") | |
if err != nil { | |
fmt.Printf("error: connecting to np.sqlite: %s\n", err.String()) | |
return | |
} | |
defer npconn.Close() | |
amaconn, err := dbi.Connect("sqlite://./products.sqlite") | |
if err != nil { | |
fmt.Printf("error: connecting to products.sqlite: %s\n", | |
err.String()) | |
return | |
} | |
defer amaconn.Close() | |
rs, err := npconn.Query(`SELECT product_name, model_number, list, | |
cost FROM items`) | |
if err != nil { | |
fmt.Printf("error: reading from np.sqlite: %s\n", err.String()) | |
return | |
} | |
defer rs.Close() | |
vec := new(vector.Vector) | |
for rs.Next() { | |
var product_name string | |
var model_number string | |
var list string | |
var cost string | |
err = rs.Scan(&product_name, &model_number, &list, &cost) | |
if err != nil { | |
fmt.Printf("error: %s\n", err.String()) | |
} | |
item := &BasicListing{ ProductName: product_name, ModelNumber: | |
model_number, List: list, Cost: cost} | |
vec.Push(item) | |
} | |
for i := 0; i < vec.Len(); i++ { | |
el := vec.At(i); | |
fmt.Print(el,"\n"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On branch master | |
# Untracked files: | |
# (use "git add <file>..." to include in what will be committed) | |
# | |
# np.sqlite | |
# products.sqlite | |
# status.txt | |
nothing added to commit but untracked files present (use "git add" to track) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var npcolumns = { | |
"Product Name" : "title", | |
"Model" : "mfr-part-number", | |
"Product Description" : "description", | |
"Product Features" : "bullet-point1", | |
"Chair Mechanism" : "", | |
"Dimensions (H x W x D)" : "", | |
"Box Dimensions (H x W x D)" : "", | |
"Chair Weight" : "", | |
"Seat Width" : "", | |
"Seat Height" : "", | |
"Seat Depth" : "", | |
"Seat Angle" : "", | |
"Back Width" : "", | |
"Back Height" : "", | |
"Back Angle" : "", | |
"Lumbar Range" : "", | |
"Arm Height" : "", | |
"Arm Width" : "", | |
"Base Diameter" : "", | |
"Fabric Grade" : "", | |
"List" : "item-price", | |
"Our Cost" : "price" | |
}; | |
var bosscolumns = { | |
"Item Number" : "", | |
"Product Name" : "", | |
"Long Description" : "", | |
"Fabric Type" : "", | |
"Cushion Color" : "", | |
"Frame Color, Base Color, or Wood Finish" : "", | |
"UPC" : "", | |
"List UOM" : "", | |
"Weight" : "", | |
"Dimensional Weight" : "", | |
"Carton Length" : "", | |
"Carton Width" : "", | |
"Carton Height" : "", | |
"Cubic Feet" : "", | |
"Pallet Qty" : "", | |
"FOB" : "", | |
"UPS/FED EX" : "", | |
"Seat Size" : "", | |
"Seat Height" : "", | |
"Arm Height" : "", | |
"Overall Size" : "", | |
"WT. Capacity" : "", | |
"Category" : "", | |
"Country of Orgin" : "", | |
"id" : "", | |
"title" : "", | |
"link" : "", | |
"price" : "", | |
"description" : "", | |
"condition" : "", | |
"gtin" : "", | |
"brand" : "", | |
"mpn" : "", | |
"image_link" : "", | |
"list_price" : "", | |
"cost" : "", | |
"markup" : "", | |
"markup_percent" : "", | |
"profit_margin" : "" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "trans" | |
func main() { | |
trans.NpToAmazon() | |
trans.NpToMagento() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment