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. 13
      sensospot_data/__init__.py

4
README.md

@ -44,7 +44,9 @@ Arguments: @@ -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.
```

13
sensospot_data/__init__.py

@ -6,6 +6,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis. @@ -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 @@ -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): @@ -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")

Loading…
Cancel
Save