<commit_before><?php
namespace Imtigger\OneExcel\Writer;

use Imtigger\OneExcel\Format;
use Imtigger\OneExcel\OneExcelWriterInterface;

class FPutCsvWriter extends OneExcelWriter implements OneExcelWriterInterface
{
    public static $input_format_supported = [Format::CSV];
    public static $output_format_supported = [Format::CSV];
    public static $input_output_same_format = true;
    private $input_format;
    private $output_format;
    private $last_row = 0;
    private $data = [];
    private $temp_file;
    private $handle;

    public function create($output_format = Format::CSV)
    {
        $this->checkFormatSupported($output_format);
        $this->output_format = $output_format;
        $this->temp_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fputcsv-' . time();
        $this->handle = fopen($this->temp_file, 'w');
    }

    public function load($filename, $output_format = Format::XLSX, $input_format = Format::AUTO)
    {
        $this->checkFormatSupported($output_format, $input_format);

        $this->input_format = $input_format;
        $this->output_format = $output_format;

        if (($handle = fopen($filename, "r")) !== FALSE) {
            $this->create($output_format);
            while (($data = fgetcsv($handle)) !== FALSE) {
                // Skip empty rows
                if(!array_filter($row)) {
                    continue;
                }
                fputcsv($this->handle, $data);
                $this->last_row += 1;
            }
            fclose($handle);
        } else {<commit_msg>Cleanup<commit_after><?php
namespace Imtigger\OneExcel\Writer;

use Imtigger\OneExcel\Format;
use Imtigger\OneExcel\OneExcelWriterInterface;

class FPutCsvWriter extends OneExcelWriter implements OneExcelWriterInterface
{
    public static $input_format_supported = [Format::CSV];
    public static $output_format_supported = [Format::CSV];
    public static $input_output_same_format = true;
    private $input_format;
    private $output_format;
    private $last_row = 0;
    private $data = [];
    private $temp_file;
    private $handle;

    public function create($output_format = Format::CSV)
    {
        $this->checkFormatSupported($output_format);
        $this->output_format = $output_format;
        $this->temp_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fputcsv-' . time();
        $this->handle = fopen($this->temp_file, 'w');
    }

    public function load($filename, $output_format = Format::XLSX, $input_format = Format::AUTO)
    {
        $this->checkFormatSupported($output_format, $input_format);

        $this->input_format = $input_format;
        $this->output_format = $output_format;

        if (($handle = fopen($filename, "r")) !== FALSE) {
            $this->create($output_format);
            while (($row = fgetcsv($handle)) !== FALSE) {
                // Skip empty rows
                if(!array_filter($row)) {
                    continue;
                }
                fputcsv($this->handle, $row);
                $this->last_row += 1;
            }
            fclose($handle);
        } else {
{'fraction_non_alphanumeric': 0.12845215157353887, 'fraction_numerical': 0.0012845215157353885, 'mean_word_length': 2.660399529964747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '7651431', 'n_tokens_mistral': 938, 'n_tokens_neox': 901, 'n_words': 174}