diff --git a/src/tagui_parse.php b/src/tagui_parse.php index 58f3b111..c55009a6 100755 --- a/src/tagui_parse.php +++ b/src/tagui_parse.php @@ -16,9 +16,8 @@ $header_file = fopen('tagui_header.js','r') or die("ERROR - cannot open tagui_header.js" . "\n"); $footer_file = fopen('tagui_footer.js','r') or die("ERROR - cannot open tagui_footer.js" . "\n"); -$repo_count = 0; if (file_exists(getenv('custom_csv_file'))) { // load repository file for objects and keywords +$repo_count = 0; if (file_exists(getenv('custom_csv_file'))) { // load datatable or legacy datatable / repository $repo_file = fopen(getenv('custom_csv_file'),'r') or die("ERROR - cannot open " . getenv('custom_csv_file') . "\n"); -fgetcsv($repo_file); // discard header record without incrementing counter while (!feof($repo_file)) {$repo_data[$repo_count] = fgetcsv($repo_file); if (count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . getenv('custom_csv_file') . "\n"); $repo_count++;} fclose($repo_file); $repo_count-=1; //-1 for header, for EOF need to check flexibly using below line @@ -27,7 +26,7 @@ $local_repo_location = str_replace("\\","/",dirname($script)) . '/tagui_local.csv'; if (file_exists($local_repo_location)) { // load local repository file if it exists for objects and keywords $local_repo_file = fopen($local_repo_location,'r') or die("ERROR - cannot open " . 'tagui_local.csv' . "\n"); -fgetcsv($local_repo_file); // discard header record without incrementing counter +if ($repo_count != 0) $repo_count++; fgetcsv($local_repo_file); // +1 if array has data, discard header record while (!feof($local_repo_file)) {$repo_data[$repo_count] = fgetcsv($local_repo_file); if (count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . 'tagui_local.csv' . "\n"); if (count($repo_data[$repo_count]) != 1) // pad the empty columns when local repository is used with datatable @@ -36,7 +35,7 @@ if (file_exists('tagui_global.csv')) { // load global repository file if it exists for objects and keywords $global_repo_file = fopen('tagui_global.csv','r') or die("ERROR - cannot open " . 'tagui_global.csv' . "\n"); -fgetcsv($global_repo_file); // discard header record without incrementing counter +if ($repo_count != 0) $repo_count++; fgetcsv($global_repo_file); // +1 if array has data, discard header record while (!feof($global_repo_file)) {$repo_data[$repo_count] = fgetcsv($global_repo_file); if (count($repo_data[$repo_count]) == 0) die("ERROR - empty row found in " . 'tagui_global.csv' . "\n"); if (count($repo_data[$repo_count]) != 1) // pad the empty columns when global repository is used with datatable