diff --git a/README.md b/README.md index 991342f..e7a7467 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,9 @@ Arguments: SOURCE: Folder with Sensospot measurement Options: - -o, --outfile TEXT Output file name, relative to SOURCE, defaults to 'collected_data.csv' + -o, --outfile TEXT Output file name, use a dash '-' for stdout, default: + 'collected_data.csv' + -q, --quiet Ignore Sanity Check --help Show this message and exit. ``` diff --git a/sensospot_data/__init__.py b/sensospot_data/__init__.py index 9dad0a0..8990ed8 100644 --- a/sensospot_data/__init__.py +++ b/sensospot_data/__init__.py @@ -6,6 +6,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis. __version__ = "0.6.0" +import sys from pathlib import Path import click @@ -29,7 +30,10 @@ from .parameters import ExposureInfo # noqa: F401 "-o", "--outfile", default="collected_data.csv", - help="Output file name", + help=( + "Output file name, use a dash '-' for stdout, " + "default: 'collected_data.csv'" + ), ) @click.option( "-q", @@ -42,5 +46,8 @@ def run(source, outfile, quiet=False): source_path = Path(source) # read the raw data of a folder raw_data = parse_folder(source_path, quiet=quiet) - csv_file = source_path / outfile - raw_data.to_csv(csv_file, sep="\t") + if outfile.strip() == "-": + raw_data.to_csv(sys.stdout, sep="\t") + else: + csv_file = source_path / outfile + raw_data.to_csv(csv_file, sep="\t")