Skip to content

Commit

Permalink
data loading scripts - loads from bestbuy json dataset products.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Koushik Biswas committed May 21, 2017
1 parent 93f5438 commit 5ee6130
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions loaddatastore.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
'projectId' => $projectId
]);

if (sizeof($argv) <= 3) {
if (sizeof($argv) == 3) {
$transaction = $datastore->transaction();
$key = $datastore->key('SKU', $argv[1]);
$product = $datastore->entity( $key, [
'name' => $argv[2]
'name' => strtolower($argv[2])
]);
$datastore->upsert($product);
$transaction->commit();
Expand Down
8 changes: 8 additions & 0 deletions loaddatastore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

readarray -t LINES < "$1"
for LINE in "${LINES[@]}"; do
sku=`echo $LINE | sed "s/^.\?{\"sku\":\([0-9]\+\),\"name\":\"\([^\"]\+\)\".*$/\1/g"`
name=`echo $LINE | sed "s/^.\?{\"sku\":\([0-9]\+\),\"name\":\"\([^\"]\+\)\".*$/\2/g"`
php loaddatastore.php "$sku" "$name"
done

0 comments on commit 5ee6130

Please sign in to comment.