diff --git a/lib/csvlib.class.php b/lib/csvlib.class.php
index 9cf39db..7c89dab 100644
--- a/lib/csvlib.class.php
+++ b/lib/csvlib.class.php
@@ -78,7 +78,7 @@ class csv_import_reader {
      * @param string $column_validation name of function for columns validation, must have one param $columns
      * @return bool false if error, count of data lines if ok; use get_error() to get error string
      */
-    function load_csv_content(&$content, $encoding, $delimiter_name, $column_validation=null) {
+    function load_csv_content(&$content, $encoding, $delimiter_name, $column_validation=null, $enclosure_name) {
         global $USER, $CFG;
 
         $this->close();
@@ -98,10 +98,15 @@ class csv_import_reader {
             return false;
         }
         $csv_delimiter = csv_import_reader::get_delimiter($delimiter_name);
+        $csv_enclosure = csv_import_reader::get_enclosure($enclosure_name);
         $csv_encode    = csv_import_reader::get_encoded_delimiter($delimiter_name);
 
         // process header - list of columns
+        if (empty($csv_enclosure)) {
         $columns   = explode($csv_delimiter, $columns);
+        } else {
+            $columns   = explode($csv_enclosure.$csv_delimiter.$csv_enclosure, substr($columns,1,-1));
+        }
         $col_count = count($columns);
         if ($col_count === 0) {
             $this->_error = get_string('csvemptyfile', 'error');
@@ -129,7 +134,11 @@ class csv_import_reader {
         $line = strtok("\n");
         $data_count = 0;
         while ($line !== false) {
+            if (empty($csv_delimiter)) {
             $line = explode($csv_delimiter, $line);
+            } else {
+                $line = explode($csv_enclosure.$csv_delimiter.$csv_enclosure, substr($line,1,-1));
+            }
             foreach ($line as $key=>$value) {
                 $line[$key] = str_replace($csv_encode, $csv_delimiter, trim($value));
             }
@@ -283,6 +292,15 @@ class csv_import_reader {
             case 'comma':     return ',';
         }
     }
+    /**
+     * Get enclosure character
+     *
+     * @param string enclosure name
+     * @return string enclosure char
+     */
+    static function get_enclosure($enclosure_name) {
+        return is_null($enclosure_name) ? '' : $enclosure_name;
+    }
 
     /**
      * Get encoded delimiter character
diff --git a/mod/data/import.php b/mod/data/import.php
index 3110490..2289d23 100644
--- a/mod/data/import.php
+++ b/mod/data/import.php
@@ -100,7 +100,7 @@ if (!$formdata = $form->get_data()) {
     $iid = csv_import_reader::get_new_iid('moddata');
     $cir = new csv_import_reader($iid, 'moddata');
 
-    $readcount = $cir->load_csv_content($form->get_file_content('recordsfile'), $formdata->encoding, $formdata->fielddelimiter);
+    $readcount = $cir->load_csv_content($form->get_file_content('recordsfile'), $formdata->encoding, $formdata->fielddelimiter, null, $fieldenclosure);
     if (empty($readcount)) {
         print_error('csvfailed','data',"{$CFG->wwwroot}/mod/data/edit.php?d={$data->id}");
     } else {
