<commit_before><?php
/**
 * @package plugins.youTubeDistribution
 * @subpackage lib
 */
class YouTubeDistributionCsvParser
{
	/**
	 * @var array
	 */
	protected $rows;

	/**
	 * YouTubeDistributionCsvParser constructor.
	 * @param $csvStr
	 */
	public function __construct($csvStr)
	{
		$all_rows = array();
		$csvArray = explode("\n", $csvStr);
		$header = explode(",", array_shift($csvArray));
		foreach ($csvArray as $row)
		{
			$rowArray = explode(",", $row);
			if (!empty($rowArray))
				$all_rows[] = array_combine($header, $rowArray);
		}

		$this->rows = $all_rows;
		KalturaLog::debug("Parsed Csv Result:" . print_r($this->rows, true));
<commit_msg>PLAT-8583 handle empty rows on Csv parser<commit_after><?php
/**
 * @package plugins.youTubeDistribution
 * @subpackage lib
 */
class YouTubeDistributionCsvParser
{
	/**
	 * @var array
	 */
	protected $rows;

	/**
	 * YouTubeDistributionCsvParser constructor.
	 * @param $csvStr
	 */
	public function __construct($csvStr)
	{
		$all_rows = array();
		$csvArray = explode("\n", $csvStr);
		$header = explode(",", array_shift($csvArray));
		foreach ($csvArray as $row)
		{
			if (empty($row))
				continue;
			$rowArray = explode(",", $row);
			$all_rows[] = array_combine($header, $rowArray);
		}

		$this->rows = $all_rows;
		KalturaLog::debug("Parsed Csv Result:" . print_r($this->rows, true));

{'fraction_non_alphanumeric': 0.17638376383763837, 'fraction_numerical': 0.002952029520295203, 'mean_word_length': 4.175572519083969, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7665562', 'n_tokens_mistral': 509, 'n_tokens_neox': 460, 'n_words': 97}