Skip to content

Commit

Permalink
Keep trying to find headers when some collated files are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed May 4, 2021
1 parent 736aa1f commit 0ca1b55
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions micall/monitor/kive_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,10 @@ def copy_outputs(self,
if output_name.endswith('_fasta'):
self.extract_fasta(source, target, sample_name)
else:
self.extract_csv(source, target, sample_name, source_count)
self.extract_csv(source,
target,
sample_name,
source_count)
source_count += 1
except FileNotFoundError:
# Skip the file.
Expand All @@ -632,8 +635,8 @@ def extract_csv(source, target, sample_name, source_count):
reader = DictReader(source)
fieldnames = reader.fieldnames
if fieldnames is None:
# Empty file, nothing to copy.
return
# Empty file, nothing to copy. Raise error to keep source_count at 0.
raise FileNotFoundError(f'CSV file {source.name} is empty.')
fieldnames = list(fieldnames)
has_sample = 'sample' in fieldnames
if not has_sample:
Expand Down

0 comments on commit 0ca1b55

Please sign in to comment.