跳到主要內容

發表文章

目前顯示的是 10月, 2013的文章

BigQuery - Load data from GCS Hint

從一般資料載入BigQuery不難,可以透過bq指令,或是web介面操作... 本篇介紹透過GCS(Google Cloud Storage)... // 載入資料到Datastore gsutil cp -R $DATA_FOLDER/$DATA_FILE gs://$BUCKET/$DATA_FOLDER // 透過bq做啟動server的變數 bq load --source_format NEWLINE_DELIMITED_JSON [dataset name].[table name] gs://$BUCKET/$DATA_FOLDER/$DATA_FILE ./schema.json 給大家參考...

BigQuery - Load JSON file to BigQuery

使用BigQuery的第一步,原則上就是開始把資料丟上BigQuery... 在Google Cloud Platform中有許多產品已經支援直接upload到BigQuery中,可以參考 官方網站 的說明... 這邊介紹的是如何將現成的JSON data匯入到BigQuery中(因為CSV相對簡單許多,這邊不贅述CSV的載入),使用到的工具是gsutil,建議可使用Cloud Platform整合版本的(這邊可以 下載 ) Sample Schema (1 record only) BigQuery原則上吃csv與json兩種格式,其中json格式與標準的json有些許不同,他強調的是 NEWLINE_DELIMITED_JSON,也就是說,每筆row之間是使用斷行隔開,而且每筆row就是獨立的一筆json資料欄... 但有別於csv,json格式的檔案是允許內部再有子階層的資料型態,以本範例為例,items為新的一個json array,可想像成RDBMS中的detail table資料... {  "transaction_time": "2013-10-20T14:32:22",  "transaction_id": 50124,  "total_spending": 300,  "coupon_discount": 20,  "items": [    {      "name": "xt920",      "category": "mobile",      "quantity": 10,      "spending": 320    },    {      "name": "xt920b",      "category": "battery",      "quantity": 11,

Connect Cloud Platform BigQuery using Node.js

This is a demo for using Node.js to query BitQuery API. We know Node.js has fast way to connect to RESTful API. In this example, we use gapitoken module to retrieve the auth token, and use request module to connect the RESTful API. Auth is the important thing in Google's API... If you pass this gate, you can access almost all Google API! Step 1: Create a service account from Google API console Save the client_secrets.json to project folder Step 2: Generate PEM key from P12 key $ openssl pkcs12 -in privatekey.p12 -out privatekey.pem -nocerts $ openssl rsa -in privatekey.pem -out key.pem Put the pem key to your project Step 3: Prepare Node.js environment a. Download and install Node.js runtime:  http://nodejs.org/ b. Install project dependency $ npm install gapitoken request Step 4: Sample Code (sample.js) var GAPI = require('gapitoken')   , request = require('request')   , fs = require('fs')   , util = require('util') //From ad

GAE上傳專案錯誤處理 - appcfg rollback

GAE是Google Cloud Platform上的一個大服務,提供穩定且自動Scale的平台,一般操作都是透過Eclipse的外掛來開發,但是今天遇到一個上傳不上去的問題... IDE卻沒有提供操作Function可以處理(或是我沒看到@@),重開Eclipse數次未能解決... 經由log檔案提供的資訊,針對AppEngine的Command Line服務來下手.... 一般user可以在Eclipse的plugin folder的下面路徑底下找到相關的執行檔案: $ ~/opt/eclipse-juno-SR2/plugins/com.google.appengine.eclipse.sdkbundle_1.7.6/appengine-java-sdk-1.7.6/bin/ 中間的"sdkbundle_..."要視SDK版本而定,操作時候記得將權限開放給操作者使用(ex: Mac user需要透過chmod來開放執行權限..) 處理AppEngine無法上傳之問題,錯誤: com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=gae-project-name&version=2& 409 Conflict Another transaction by user simonsu is already in progress for app: s~gae-project-name, version: 2. That user can undo the transaction with "appcfg rollback". 操作描述: $ cd ~/opt/eclipse-juno-SR2/plugins/com.google.appengine.eclipse.sdkbundle_1.7.6/appengine-java-sdk-1.7.6/bin/ $ appcfg.sh update war/ *************************

悄悄地…Google Book上線了…

有一陣子沒注意Google Play上的資訊了… Google Book可以使用了!!