<commit_before><?php

/**
 * @package         Billing
 * @copyright       Copyright (C) 2012-2015 S.D.O.C. LTD. All rights reserved.
 * @license         GNU Affero General Public License Version 3; see LICENSE.txt
 */

/**
 * Billing Importer Csv Simple
 * Imports from Csv to mongo collection
 *
 * @package  Billrun
 * @since    4.0
 */
class Billrun_Importer_Csv_Simple extends Billrun_Importer_Csv {
	
	protected $collectionName = null;
	protected $fieldToImport = null;
	protected $dataToImport = null;
	protected $importerName = null;
	
	public function __construct($options) {
		parent::__construct($options);
		Billrun_Factory::config()->addConfig(APPLICATION_PATH . "/conf/importers/conf.ini");
	}
	
	protected function getCollectionName() {
		$ret = pathinfo($this->getPath(), PATHINFO_FILENAME);
		return $ret;
	}
	
	/**
	 * Gets the fields to save in the document
	 * 
	 * @return type
	 */
	protected function getImporterFields() {
		if (empty($this->fieldToImport)) {
			$this->fieldToImport = fgetcsv($this->handle, $this->limit, $this->delimiter);
		}
		return $this->fieldToImport;
	}
	
	public function getRowsIndexesToSkip() {
		return array();
	}

	protected function getDataToSave($rowData) {
		$ret = array();
		foreach ($this->fields as $field => $rowFieldIndex) {
			$ret[$rowFieldIndex] = $rowData[$field];
		}
		return $ret;
	}<commit_msg>trim csv simple migrator values<commit_after><?php

/**
 * @package         Billing
 * @copyright       Copyright (C) 2012-2015 S.D.O.C. LTD. All rights reserved.
 * @license         GNU Affero General Public License Version 3; see LICENSE.txt
 */

/**
 * Billing Importer Csv Simple
 * Imports from Csv to mongo collection
 *
 * @package  Billrun
 * @since    4.0
 */
class Billrun_Importer_Csv_Simple extends Billrun_Importer_Csv {
	
	protected $collectionName = null;
	protected $fieldToImport = null;
	protected $dataToImport = null;
	protected $importerName = null;
	
	public function __construct($options) {
		parent::__construct($options);
		Billrun_Factory::config()->addConfig(APPLICATION_PATH . "/conf/importers/conf.ini");
	}
	
	protected function getCollectionName() {
		$ret = pathinfo($this->getPath(), PATHINFO_FILENAME);
		return $ret;
	}
	
	/**
	 * Gets the fields to save in the document
	 * 
	 * @return type
	 */
	protected function getImporterFields() {
		if (empty($this->fieldToImport)) {
			$this->fieldToImport = fgetcsv($this->handle, $this->limit, $this->delimiter);
		}
		return $this->fieldToImport;
	}
	
	public function getRowsIndexesToSkip() {
		return array();
	}

	protected function getDataToSave($rowData) {
		$ret = array();
		foreach ($this->fields as $field => $rowFieldIndex) {
			$ret[$rowFieldIndex] = trim($rowData[$field]);
		}
		return $ret;
	}
{'fraction_non_alphanumeric': 0.13217138707334786, 'fraction_numerical': 0.007988380537400145, 'mean_word_length': 3.8934280639431615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '5512077', 'n_tokens_mistral': 954, 'n_tokens_neox': 865, 'n_words': 216}