Pixelaとは
そしてGemも
だったら過去データ用にEmbulkかな
というわけで作った。(あいかわずテスト無しjruby plugin...)
利用方法
ユーザ登録と登録対象となるグラフについては事前に作成の必要があります。
$ gem install pixela $ irb > require "pixela" > client = Pixela::Client.new(username: "YOURNAME", token: "YOURTOKEN") > client.create_user(agree_terms_of_service: true, not_minor: true) > client.create_graph(graph_id: "YOURIDNAME", name: "YOURGRAPHNAME", unit: "commit", type: "int", color: "shibafu")
これをすると、下記のようになっているはずなので。
Embulkインストール後に (Embulkの使い方はぐぐってみていただけると!)
embulk gem install embulk-output-pixela
でインストールして、下記みたいなCSVがあったときに
point,date 0,2018/10/01 1,2018/10/02 2,2018/10/03 3,2018/10/04 4,2018/10/05 5,2018/10/06 6,2018/10/07 7,2018/10/08 8,2018/10/09 9,2018/10/10 10,2018/10/11 11,2018/10/12 12,2018/10/13 13,2018/10/14 14,2018/10/15
下記の設定ファイルを用意して、
in:
type: file
path_prefix: test.csv
parser:
charset: UTF-8
newline: CRLF
type: csv
delimiter: ','
quote: '"'
escape: '"'
trim_if_not_quoted: false
skip_header_lines: 1
allow_extra_columns: false
allow_optional_columns: false
columns:
- {name: point, type: long}
- {name: date, type: timestamp, format: '%Y/%m/%d'}
out:
type: pixela
name: torut
token: xxxx
graph_id: embulk-test
quantity_int_column: point
date_column: date
Embulkを実行すると取り込めます。
embulk run example.yml
参考:
今の所、各日付の新規追加しかできず、既存のアップデートなどはできません。
なんか手元にデータがあって、とりあえずインポートしたいってときにでも試して見てください。