Browse Source

added the possibility to redirect parsed data to stdout

xmlparsing
Holger Frey 3 years ago
parent
commit
c1f1e2bb0e
  1. 4
      README.md
  2. 9
      sensospot_data/__init__.py

4
README.md

@ -44,7 +44,9 @@ Arguments:
SOURCE: Folder with Sensospot measurement SOURCE: Folder with Sensospot measurement
Options: 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. --help Show this message and exit.
``` ```

9
sensospot_data/__init__.py

@ -6,6 +6,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis.
__version__ = "0.6.0" __version__ = "0.6.0"
import sys
from pathlib import Path from pathlib import Path
import click import click
@ -29,7 +30,10 @@ from .parameters import ExposureInfo # noqa: F401
"-o", "-o",
"--outfile", "--outfile",
default="collected_data.csv", default="collected_data.csv",
help="Output file name", help=(
"Output file name, use a dash '-' for stdout, "
"default: 'collected_data.csv'"
),
) )
@click.option( @click.option(
"-q", "-q",
@ -42,5 +46,8 @@ def run(source, outfile, quiet=False):
source_path = Path(source) source_path = Path(source)
# read the raw data of a folder # read the raw data of a folder
raw_data = parse_folder(source_path, quiet=quiet) raw_data = parse_folder(source_path, quiet=quiet)
if outfile.strip() == "-":
raw_data.to_csv(sys.stdout, sep="\t")
else:
csv_file = source_path / outfile csv_file = source_path / outfile
raw_data.to_csv(csv_file, sep="\t") raw_data.to_csv(csv_file, sep="\t")

Loading…
Cancel
Save