/**
  * Construct
  * @param string $fileName
  */
 public function __construct($fileName)
 {
     $Reader = new BigFileReaderGZip($fileName);
     while (!$Reader->eof()) {
         $Line = trim($Reader->readLine());
         if (substr($Line, 0, 8) == '{"TABLE"') {
             $TableName = substr($Line, 10, -2);
             $this->NumberOf[$TableName] = 0;
         } elseif ($Line != '' && $Line[0] == '{') {
             $this->NumberOf[$TableName]++;
         }
     }
     $Reader->close();
 }
 /**
  * Import table
  * @param string $TableName
  */
 private function importTable($TableName)
 {
     $Line = $this->Reader->readLine();
     if ($Line[0] != '{') {
         return;
     }
     $CompleteRow = json_decode($Line, true);
     $Row = array_shift($CompleteRow);
     $Columns = array_keys($Row);
     $BulkInsert = new RunalyzeBulkInsert($TableName, $Columns, $this->AccountID);
     while ($Line[0] == '{') {
         $CompleteRow = json_decode($Line, true);
         $ID = key($CompleteRow);
         $Row = current($CompleteRow);
         $Values = array_values($Row);
         if ($Columns[0] == 'name' || $TableName == 'runalyze_plugin') {
             if (isset($this->ExistingData[$TableName][$Values[0]])) {
                 $this->ReplaceIDs[$TableName][$ID] = $this->ExistingData[$TableName][$Values[0]];
             } else {
                 $this->ReplaceIDs[$TableName][$ID] = $BulkInsert->insert($Values);
                 $this->Results->addInserts($TableName, 1);
             }
         } else {
             $this->correctValues($TableName, $Row);
             if ($TableName == 'runalyze_training') {
                 $this->ReplaceIDs[$TableName][$ID] = $BulkInsert->insert(array_values($Row));
             } else {
                 $BulkInsert->insert(array_values($Row));
             }
             $this->Results->addInserts($TableName, 1);
         }
         $Line = $this->Reader->readLine();
     }
 }