<commit_before># encoding: utf-8

module CartoDB
  module Importer2
    class Json2Csv
      def initialize(filepath, job=nil)
        @filepath = filepath
        @job      = job || Job.new
      end #initialize

      def run
        data = parse(filepath)
        return false if complex?(data)
        File.open(converted_filepath, 'w') { |file| file.write csv_from(data) }
        job.log 'Converting JSON to CSV'
        self
      end #run

      def csv_from(data)
        [csv_header_from(data), csv_rows_from(data)].join("\n")
      end #csv_for
<commit_msg>[importer] Require Job from Json2Csv<commit_after># encoding: utf-8
require_relative './job'

module CartoDB
  module Importer2
    class Json2Csv
      def initialize(filepath, job=nil)
        @filepath = filepath
        @job      = job || Job.new
      end #initialize

      def run
        data = parse(filepath)
        return false if complex?(data)
        File.open(converted_filepath, 'w') { |file| file.write csv_from(data) }
        job.log 'Converting JSON to CSV'
        self
      end #run

      def csv_from(data)
        [csv_header_from(data), csv_rows_from(data)].join("\n")
      end #csv_for

{'fraction_non_alphanumeric': 0.10135135135135136, 'fraction_numerical': 0.0059121621621621625, 'mean_word_length': 2.3380281690140845, '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': '5000674', 'n_tokens_mistral': 395, 'n_tokens_neox': 378, 'n_words': 98}