# File lib/hammer_cli_csv/puppet_facts.rb, line 36
      def export
        CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
          headers = [NAME, COUNT]
          # Extracted facts are always based upon the first host found, otherwise this would be an intensive
          # method to gather all the possible column names
          any_host = @api.resource(:hosts).call(:index, {:per_page => 1})['results'][0]
          headers += @api.resource(:puppetfactss).call(:index, {
                                                         'host_id' => any_host['name'],
                                                         'per_page' => 999999
                                                       })['results'][any_host['name']].keys
          csv << headers

          @api.resource(:hosts).call(:index, {:per_page => 999999})['results'].each do |host|
            line = [host['name'], 1]
            facts = @api.resource(:puppetfactss).call(:index, {'host_id' => host['name'], 'per_page' => 999999})[host['name']]
            facts ||= {}
            headers[2..-1].each do |fact_name|
              line << facts[fact_name] || ''
            end
            csv << line
          end
        end
      end