Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

… doesn't throw errors.
  • Loading branch information...
commit 415a6ffcc87d6a5ffa3d8979969abeaffbf9f31e 1 parent 6109f21
@abgreeve abgreeve authored
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;
Please sign in to comment.
Something went wrong with that request. Please try again.