<commit_before># encoding: utf-8
require 'forwardable'
require_relative './ogr2ogr'
require_relative './georeferencer'

module CartoDB
  module Importer2
    class Loader
      extend Forwardable

      SCHEMA        = 'importer'
      TABLE_PREFIX  = 'importer'

      def initialize(job, source_file, ogr2ogr=nil, georeferencer=nil)
        self.job            = job
        self.source_file    = source_file
        self.ogr2ogr        = ogr2ogr
        self.georeferencer  = georeferencer
      end #initialize

      def run
        job.log "Using database connection #{job.pg_options}"<commit_msg>[importer] Preprocess JSON files in Loader<commit_after># encoding: utf-8
require 'forwardable'
require_relative './ogr2ogr'
require_relative './json2csv'
require_relative './georeferencer'

module CartoDB
  module Importer2
    class Loader
      extend Forwardable

      SCHEMA        = 'importer'
      TABLE_PREFIX  = 'importer'

      def initialize(job, source_file, ogr2ogr=nil, georeferencer=nil)
        self.job            = job
        self.source_file    = source_file
        self.ogr2ogr        = ogr2ogr
        self.georeferencer  = georeferencer
      end #initialize

      def run
        job.log "Using database connection #{job.pg_options}"

        if source_file.extension == '.json'
          json2csv = Json2Csv.new(source_file.fullpath, job)
          json2csv.run
          self.source_file = SourceFile.new(json2csv.converted_filepath)
        end
{'fraction_non_alphanumeric': 0.0777552400270453, 'fraction_numerical': 0.011494252873563218, 'mean_word_length': 2.457943925233645, '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': '4810747', 'n_tokens_mistral': 468, 'n_tokens_neox': 445, 'n_words': 102}