CSVをGoogleスプレッドシートに自動入力したいです。
google_driveのgemを使って、CSVをスプレッドシートに自動で入力する場合、
コードでCSVをパースしてから、各列に代入していく形が最適でしょうか?
それとも、CSVファイルをそのままアップしてうまくいく例などを知っている方いますか?(調べても出てきませんでした。)
CSVを、スプレッドシートに自動入力したいのですが、詳しい方いたら教えてください。
プログラミングのレベルがまだ低いので、トンチンカンなことを言っていたら申し訳ありません。
参考URL
https://github.com/gimite/google-drive-ruby
スプレッドシートに“foo”,“bar”を書く例。
require "google_drive" # Creates a session. This will prompt the credential via command line for the # first time and save it to config.json file for later usages. # See this document to learn how to create config.json: # https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md session = GoogleDrive::Session.from_config("config.json") # First worksheet of # https://docs.google.com/spreadsheet/ccc?key=pz7XtlQC-PYx-jrVMJErTcg # Or https://docs.google.com/a/someone.com/spreadsheets/d/pz7XtlQC-PYx-jrVMJErTcg/edit?usp=drive_web ws = session.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg").worksheets[0] # Gets content of A2 cell. p ws[2, 1] #==> "hoge" # Changes content of cells. # Changes are not sent to the server until you call ws.save(). ws[2, 1] = "foo" ws[2, 2] = "bar" ws.save # Dumps all cells. (1..ws.num_rows).each do |row| (1..ws.num_cols).each do |col| p ws[row, col] end end # Yet another way to do so. p ws.rows #==> [["fuga", ""], ["foo", "bar]] # Reloads the worksheet to get changes by other clients. ws.reload
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。