<commit_before>class Timecapsule

  config = YAML.load_file(Rails.root.join("config/timecapsule.yml")
  IMPORT_DIR = config[:import_directory] || 'db/seed_data/'
  EXPORT_DIR = config[:export_directory] || 'db/seed_data/'
  
  require 'csv'
  
  def self.import_model(model_import)
    puts "Importing: #{model_import} from #{IMPORT_DIR}#{model_import.to_s.pluralize.underscore}.csv"
    csv = CSV.read(Rails.root.join("#{IMPORT_DIR}#{model_import.to_s.pluralize.underscore}.csv"))
    attributes = csv.shift
    csv.each do |row|
      hash = {}
      attributes.collect{|k| k.to_sym}.each_with_index do |key,i|
        hash[key] = row[i]
      end
      object = model_import.new(hash)
      object.save(false)
    end
  end
  
  def self.import
    @csv_files = Dir.glob("#{IMPORT_DIR}*.csv")
    @csv_files.each do |file|
      model_name = file.split('/').last.split('.').first.classify.constantize
      if model_name.count == 0
        Timecapsule.import_model(model_name)
      end
    end
  end
  
  def self.export_model(model_export)
    puts "Exporting: #{model_export} to #{EXPORT_DIR}#{model_export.to_s.pluralize.underscore}.csv"<commit_msg>fix the syntax error<commit_after>class Timecapsule

  config = YAML.load_file(Rails.root.join("config/timecapsule.yml"))
  IMPORT_DIR = config[:import_directory] || 'db/seed_data/'
  EXPORT_DIR = config[:export_directory] || 'db/seed_data/'
  
  require 'csv'
  
  def self.import_model(model_import)
    puts "Importing: #{model_import} from #{IMPORT_DIR}#{model_import.to_s.pluralize.underscore}.csv"
    csv = CSV.read(Rails.root.join("#{IMPORT_DIR}#{model_import.to_s.pluralize.underscore}.csv"))
    attributes = csv.shift
    csv.each do |row|
      hash = {}
      attributes.collect{|k| k.to_sym}.each_with_index do |key,i|
        hash[key] = row[i]
      end
      object = model_import.new(hash)
      object.save(false)
    end
  end
  
  def self.import
    @csv_files = Dir.glob("#{IMPORT_DIR}*.csv")
    @csv_files.each do |file|
      model_name = file.split('/').last.split('.').first.classify.constantize
      if model_name.count == 0
        Timecapsule.import_model(model_name)
      end
    end
  end
  
  def self.export_model(model_export)
    puts "Exporting: #{model_export} to #{EXPORT_DIR}#{model_export.to_s.pluralize.underscore}.csv"
{'fraction_non_alphanumeric': 0.1418103448275862, 'fraction_numerical': 0.0008620689655172414, 'mean_word_length': 3.5509803921568626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1955641', 'n_tokens_mistral': 848, 'n_tokens_neox': 837, 'n_words': 126}