Skip to content

Commit

Permalink
Merge pull request #1181 from dsenalik/1180-tv3-bulk_loader_line_count
Browse files Browse the repository at this point in the history
1180 tv3 bulk loader line count
  • Loading branch information
spficklin committed Mar 29, 2021
2 parents 52599c8 + 10c68a5 commit 8819aad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tripal_bulk_loader/includes/tripal_bulk_loader.chado_node.inc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function tripal_bulk_loader_form($node, $form_state) {
$form['loader']['has_header'] = [
'#type' => 'radios',
'#title' => t('File has a Header'),
'#options' => [1 => 'Yes', 2 => 'No'],
'#options' => [1 => 'Yes', 0 => 'No'],
'#weight' => -7,
'#default_value' => (isset($node->file_has_header)) ? $node->file_has_header : 1,
];
Expand Down Expand Up @@ -408,4 +408,4 @@ function tripal_bulk_loader_node_view($node, $view_mode, $langcode) {
}
break;
}
}
}
13 changes: 10 additions & 3 deletions tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,14 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
$total_lines++;
}
fclose($handle);
// do not count header line in the non-blank line count
if (($total_lines) and (preg_match('/(t|true|1)/', $node->file_has_header))) {
$total_lines--;
}

// 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";
print "File: " . $node->file . " (" . $total_lines . " lines with data)\n";

//print "\nClearing all prepared statements from previous runs of this loader...\n";
//tripal_core_chado_clear_prepared('_'.$node->nid.'_');
Expand Down Expand Up @@ -397,7 +401,10 @@ function tripal_bulk_loader_load_data($nid, $job_id) {

// percentage of lines processed for the current group
$group_progress = round(($num_lines / $total_lines) * 100);
tripal_bulk_loader_progress_bar($num_lines, $total_lines);
// don't show progress for the last line, that is printed at the end of this function
if ($num_lines < $total_lines) {
tripal_bulk_loader_progress_bar($num_lines, $total_lines);
}

// percentage of lines processed for all groups
// <previous group index> * 100 + <current group progress>
Expand Down Expand Up @@ -476,7 +483,7 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
$loaded_without_errors = FALSE;
break;
}
tripal_bulk_loader_progress_bar($total_lines, $total_lines);
tripal_bulk_loader_progress_bar($num_lines, $total_lines);
tripal_bulk_loader_progress_file_track_job($job_id, FALSE, FALSE, TRUE);
} //end of foreach constant set

Expand Down

0 comments on commit 8819aad

Please sign in to comment.