(require '[api.service.tools :as csv]) (require '[pipeline.youtube.api :as api]) (require '[api.channel :as c]) (require '[api.cms :as cms]) (defn foobar [infile outfile country] (->> (slurp infile) (csv/csv-to-map) (map #(assoc % :cms-name (->> (c/get :id (:id %) :fields [:cms]) :cms (cms/get :id) :name))) (map #(assoc % :country country)) (map #(assoc % :earnings (->> (api/get-metrics [(:id %)] ;:cms-name (:cms-name %) :start "2016-01-01" :end "2017-01-01" :country country :metrics "estimatedRevenue") first :earnings))) ;(map #(println %)) map-to-csv (spit outfile) )) (foobar "/home/ubuntu/2016-channel-list-test.csv" "/home/ubuntu/2016-channel-list-global.csv" nil)