<commit_before>#!/usr/bin/env ruby

require 'csv'

if ARGV.length < 2
  puts "Usage: moodle-destroyer moodle-file grading-file [output-file]"
  puts "Please run this command in the directory where your CSV files are located."
  exit 1
end

moodle_export = ARGV[0]
grading_file  = ARGV[1]
result_file   = ARGV[2]

if result_file == nil
  result_file = "result.csv"
end

moodle_csv = CSV.read(moodle_export)

CSV.open(result_file, "wb") do |csv| 
  csv << moodle_csv[0]
  CSV.foreach(grading_file, headers: true) do |grading_row| 
    grading_row.to_hash.each do |grading_key, grading_value| 
      CSV.foreach(moodle_export, headers: true) do |row|
        row.to_hash.each do |key, value|
          if grading_value == value
            row['Bewertung'] = grading_row['Bewertung']
            row['Feedback als Kommentar'] = grading_row['Feedback als Kommentar']
            csv << row
          end
        end
      end
    end
  end
end

puts "Done... Please look into #{result_file}"

<commit_msg>Immediately exit Ruby version of moodle-destroyer<commit_after>#!/usr/bin/env ruby

require 'csv'

puts "This script is seriously buggy. Use the Python version!"
exit 1

if ARGV.length < 2
  puts "Usage: moodle-destroyer moodle-file grading-file [output-file]"
  puts "Please run this command in the directory where your CSV files are located."
  exit 1
end

moodle_export = ARGV[0]
grading_file  = ARGV[1]
result_file   = ARGV[2]

if result_file == nil
  result_file = "result.csv"
end

moodle_csv = CSV.read(moodle_export)

CSV.open(result_file, "wb") do |csv| 
  csv << moodle_csv[0]
  CSV.foreach(grading_file, headers: true) do |grading_row| 
    grading_row.to_hash.each do |grading_key, grading_value| 
      CSV.foreach(moodle_export, headers: true) do |row|
        row.to_hash.each do |key, value|
          if grading_value == value
            row['Bewertung'] = grading_row['Bewertung']
            row['Feedback als Kommentar'] = grading_row['Feedback als Kommentar']
            csv << row
          end
        end
      end
    end
  end
end

puts "Done... Please look into #{result_file}"


{'fraction_non_alphanumeric': 0.10573731626363206, 'fraction_numerical': 0.006164058795637743, 'mean_word_length': 3.1130604288499026, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3699297', 'n_tokens_mistral': 781, 'n_tokens_neox': 739, 'n_words': 203}