Browse Source

Fixed bulk loader to not use 'wc' to count lines in file

Stephen Ficklin 9 years ago
parent
commit
314f988645
1 changed files with 8 additions and 1 deletions
  1. 8 1
      tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc

+ 8 - 1
tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc

@@ -151,7 +151,14 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
   print "Template: " . $node->template->name . " (" . $node->template_id . ")\n";
 
   // Determine the total number of lines in the file.
-  $total_lines = trim(`wc --lines < $node->file`);
+  $total_lines = 0;
+  $handle = fopen($node->file, "r");
+  while(!feof($handle)){
+    $line = fgets($handle);
+    $total_lines++;
+  }
+  fclose($handle);
+
   // Correct for files with a single line and no enter character.
   $total_lines = ($total_lines == 0) ? 1 : $total_lines;
   print "File: " . $node->file . " (" . $total_lines . " lines)\n";