Sha256: f31cb299eb9b94df2bb7cf4984d170a563a17ff3abade0ee3218b414b43c2a9e

Contents?: true

Size: 902 Bytes

Versions: 6

Compression:

Stored size: 902 Bytes

Contents

# encoding: utf-8

module UsdaNutrientDatabase
  module Import
    class Foods < Base
      def import
        UsdaNutrientDatabase.log 'Importing foods'
        CSV.open("#{directory}/FOOD_DES.txt", 'r:iso-8859-1:utf-8', csv_options) do |csv|
          csv.each do |row|
            UsdaNutrientDatabase::Food.create!(
              nutrient_databank_number: row[0],
              food_group_code: row[1],
              long_description: row[2],
              short_description: row[3],
              common_names: row[4],
              manufacturer_name: row[5],
              survey: row[6],
              refuse_description: row[7],
              percentage_refuse: row[8],
              nitrogen_factor: row[9],
              protein_factor: row[10],
              fat_factor: row[11],
              carbohydrate_factor: row[12]
            )
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
usda-nutrient-database-0.4.0 lib/usda_nutrient_database/import/foods.rb
usda-nutrient-database-0.3.0 lib/usda_nutrient_database/import/foods.rb
usda-nutrient-database-0.2.0 lib/usda_nutrient_database/import/foods.rb
usda-nutrient-database-0.1.2 lib/usda_nutrient_database/import/foods.rb
usda-nutrient-database-0.1.1 lib/usda_nutrient_database/import/foods.rb
usda-nutrient-database-0.1.0 lib/usda_nutrient_database/import/foods.rb