Sha256: 481818246f860d0ae57d368d64e383b1c78d0a06550a8096de25a649d2e05cc6
Contents?: true
Size: 1.49 KB
Versions: 10
Compression:
Stored size: 1.49 KB
Contents
class Quandl::Command::Tasks::Replace < Quandl::Command::Task autoload_quandl_client description "Upload datasets and replace data instead of merging." syntax %{quandl replace file.qdf EXAMPLES: $ quandl replace file.qcsv OK | 98ms | http://quandl.com/USERNAME/CODE_1 OK | 72ms | http://quandl.com/USERNAME/CODE_2 $ ruby code.rb | quandl replace OK | 98ms | http://quandl.com/USERNAME/CODE_1 OK | 72ms | http://quandl.com/USERNAME/CODE_2 Quandl CSV Format: code: YOUR_QUANDL_CODE name: Dataset Title description: Dataset description. private: false - Date, First, Second, Third 2013-11-22,1252.0,454.95,448.2 2013-11-21,452.25,457.75,449.1 } authenticated_users_only! def execute # datasets from file_path if given interface = file_path.present? ? File.open(file_path, "r") : $stdin # for each dataset streamed from interface Quandl::Format::Dataset.each_line(interface) do |dataset, error| # present error if given next present( error ) unless error.nil? # process in background using thread key background_job( lock: dataset.client.full_code ) do # replace replace( dataset ) end end end def replace(dataset) dataset.client.delete_data # upload unless errors were raised dataset.upload if dataset.valid? # output report to $stdout or $stderr present(dataset.client) end def file_path args.first end end
Version data entries
10 entries across 10 versions & 1 rubygems