Browse files

MDL-36113 - lib: Importing csv entries with empty lines in the middle…

… doesn't throw errors.
  • Loading branch information...
1 parent 6109f21 commit 415a6ffcc87d6a5ffa3d8979969abeaffbf9f31e @abgreeve abgreeve committed Nov 5, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/csvlib.class.php
View
10 lib/csvlib.class.php
@@ -105,7 +105,15 @@ function load_csv_content(&$content, $encoding, $delimiter_name, $column_validat
// str_getcsv doesn't iterate through the csv data properly. It has
// problems with line returns.
while ($fgetdata = fgetcsv($fp, 0, $csv_delimiter, $enclosure)) {
- $columns[] = $fgetdata;
+ // Check to see if we have an empty line.
+ if (count($fgetdata) == 1) {
+ if ($fgetdata[0] !== null) {
+ // The element has data. Add it to the array.
+ $columns[] = $fgetdata;
+ }
+ } else {
+ $columns[] = $fgetdata;
+ }
}
$col_count = 0;

0 comments on commit 415a6ff

Please sign in to comment.