Skip to content

Commit

Permalink
Make collate counts output more machine readable
Browse files Browse the repository at this point in the history
Otherwise prints columns padded with spaces, which
might be more of a pain to parse later on
  • Loading branch information
mcmero committed May 19, 2024
1 parent 617b9c8 commit 1b04d11
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bin/collate_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Portability : POSIX
'''
import pandas as pd
import sys
from io import StringIO
from natsort import index_natsorted, order_by_index
from argparse import ArgumentParser

Expand Down Expand Up @@ -45,7 +47,12 @@ def main():

new_index = order_by_index(result_df.index, index_natsorted(df['guide']))
result_df = result_df.reindex(index=new_index)
print(result_df.to_string(index=False))

# write to stdout
output = StringIO()
result_df.to_csv(output, sep='\t', index=False)
output.seek(0)
print(output.read(), file=sys.stdout)


if __name__ == "__main__":
Expand Down

0 comments on commit 1b04d11

Please sign in to comment.