diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/src/SoapBox/Formatter/Formatter.php b/src/SoapBox/Formatter/Formatter.php index bfb0d0f..1f86635 100644 --- a/src/SoapBox/Formatter/Formatter.php +++ b/src/SoapBox/Formatter/Formatter.php @@ -368,12 +368,12 @@ protected function _from_csv($string, $attributes = array()) { // Get the headings $headings = str_replace($escape.$enclosure, $enclosure, str_getcsv(array_shift($rows), $delimiter, $enclosure, $escape)); - foreach ($rows as $row) { + foreach ($rows as $line_number => $row) { $data_fields = str_replace($escape.$enclosure, $enclosure, str_getcsv($row, $delimiter, $enclosure, $escape)); if (count($data_fields) > count($headings)) { - array_push(self::$errors, Lang::get('formatter::formatter.more_data', array('line_number' => $line_number ) )); + array_push(self::$errors, Lang::get('formatter::formatter.more_data', array('line_number' => $line_number + 1) )); } else if (count($data_fields) < count($headings)) { - array_push(self::$errors, Lang::get('formatter::formatter.less_data', array('line_number' => $line_number ) )); + array_push(self::$errors, Lang::get('formatter::formatter.less_data', array('line_number' => $line_number + 1) )); } else { $data[] = array_combine($headings, $data_fields); } @@ -419,4 +419,13 @@ public static function is_assoc($arr) { } return false; } + + /** + * Returns with errors + * @return array + */ + public function errors() + { + return self::$errors; + } }