Skip to content

Commit 1b04624

Browse files
authored
SDS-Convert: rename "simple_csv" to "csv" (#280)
- "simple_csv" is still supported but is not shown anywhere in command line help
1 parent b883246 commit 1b04624

2 files changed

Lines changed: 44 additions & 39 deletions

File tree

documentation/utilities.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ sds:
538538
python sds-convert.py audio_wav -i Microphone.0.sds -o microphone.wav -y Microphone.sds.yml
539539
```
540540

541-
#### Simple CSV
541+
#### CSV
542542

543-
The `simple_csv` mode converts SDS file (`.sds`) containing sensor data into a human-readable CSV file (`.csv`).
543+
The `csv` mode converts SDS file (`.sds`) containing sensor data into a human-readable CSV file (`.csv`).
544544

545545
Timeslots are represented in floating-point format, in seconds. Using the `--normalize` parameter causes
546546
all timeslots in the input file to be offset so that the first timeslot starts at `0`.
@@ -551,13 +551,13 @@ Users may specify a time range selection of the input data to be processed using
551551
- `--stop-timeslot <timeslot>` : Stopping input data timeslot in floating-point format, in seconds.
552552

553553
```txt
554-
usage: sds-convert.py simple_csv [-h]
555-
-i <input_file>
556-
-o <output_file>
557-
-y <yaml_file>
558-
[--normalize]
559-
[--start-timeslot <timeslot>]
560-
[--stop-timeslot <timeslot>]
554+
usage: sds-convert.py csv [-h]
555+
-i <input_file>
556+
-o <output_file>
557+
-y <yaml_file>
558+
[--normalize]
559+
[--start-timeslot <timeslot>]
560+
[--stop-timeslot <timeslot>]
561561
562562
Convert SDS file to CSV file with timeslots and data columns
563563
@@ -603,7 +603,7 @@ sds:
603603
**Example:**
604604

605605
```bash
606-
python sds-convert.py simple_csv -i Gyroscope.0.sds -o Gyroscope.csv -y Gyroscope.sds.yml --normalize --start-timeslot 0.2 --stop-timeslot 0.3
606+
python sds-convert.py csv -i Gyroscope.0.sds -o Gyroscope.csv -y Gyroscope.sds.yml --normalize --start-timeslot 0.2 --stop-timeslot 0.3
607607
```
608608

609609
#### Qeexo V2 CSV

utilities/sds-convert.py

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ def main():
674674

675675
subparsers = parser.add_subparsers(
676676
dest="convert_format",
677+
metavar="{audio_wav,csv,qeexo_v2_csv,video}",
677678
title="conversion formats",
678679
description="Choose a format for file conversion",
679680
help="Use '<format> --help' for format-specific options",
@@ -695,30 +696,32 @@ def main():
695696
parser_audio_wav_required.add_argument("-y", dest="yaml", metavar="<yaml_file>",
696697
help="YAML metadata file", required=True)
697698

698-
# Simple CSV
699-
parser_simple_csv = subparsers.add_parser("simple_csv",
700-
help="Convert SDS file to CSV file (single sensor)",
701-
description="Convert SDS file to CSV file with timeslots and data columns",
702-
formatter_class=formatter, add_help=False)
703-
parser_simple_csv_options = parser_simple_csv.add_argument_group("options")
704-
parser_simple_csv_options.add_argument("-h", "--help", action="help",
705-
help="Show this help message and exit")
706-
parser_simple_csv_required = parser_simple_csv.add_argument_group("required")
707-
parser_simple_csv_required.add_argument("-i", dest="in_file", metavar="<input_file>",
708-
help="Input file", type=in_file, required=True)
709-
parser_simple_csv_required.add_argument("-o", dest="out_file", metavar="<output_file>",
710-
help="Output file", type=out_file, required=True)
711-
parser_simple_csv_required.add_argument("-y", dest="yaml", metavar="<yaml_file>",
712-
help="YAML metadata file", required=True)
713-
parser_simple_csv_optional = parser_simple_csv.add_argument_group("optional")
714-
parser_simple_csv_optional.add_argument("--normalize", dest="normalize",
715-
help="Normalize timeslots so they start with 0", action="store_true")
716-
parser_simple_csv_optional.add_argument("--start-timeslot", dest="start_timeslot", metavar="<timeslot>",
717-
help="Starting input data timeslot, in seconds (default: %(default)s)",
718-
type=float, default=None)
719-
parser_simple_csv_optional.add_argument("--stop-timeslot", dest="stop_timeslot", metavar="<timeslot>",
720-
help="Stopping input data timeslot, in seconds (default: %(default)s)",
721-
type=float, default=None)
699+
# CSV
700+
parser_csv = subparsers.add_parser("csv",
701+
help="Convert SDS file to CSV file (single sensor)",
702+
description="Convert SDS file to CSV file with timeslots and data columns",
703+
formatter_class=formatter, add_help=False)
704+
# Keep the old command accepted without exposing it in generated help.
705+
subparsers._name_parser_map["simple_csv"] = parser_csv
706+
parser_csv_options = parser_csv.add_argument_group("options")
707+
parser_csv_options.add_argument("-h", "--help", action="help",
708+
help="Show this help message and exit")
709+
parser_csv_required = parser_csv.add_argument_group("required")
710+
parser_csv_required.add_argument("-i", dest="in_file", metavar="<input_file>",
711+
help="Input file", type=in_file, required=True)
712+
parser_csv_required.add_argument("-o", dest="out_file", metavar="<output_file>",
713+
help="Output file", type=out_file, required=True)
714+
parser_csv_required.add_argument("-y", dest="yaml", metavar="<yaml_file>",
715+
help="YAML metadata file", required=True)
716+
parser_csv_optional = parser_csv.add_argument_group("optional")
717+
parser_csv_optional.add_argument("--normalize", dest="normalize",
718+
help="Normalize timeslots so they start with 0", action="store_true")
719+
parser_csv_optional.add_argument("--start-timeslot", dest="start_timeslot", metavar="<timeslot>",
720+
help="Starting input data timeslot, in seconds (default: %(default)s)",
721+
type=float, default=None)
722+
parser_csv_optional.add_argument("--stop-timeslot", dest="stop_timeslot", metavar="<timeslot>",
723+
help="Stopping input data timeslot, in seconds (default: %(default)s)",
724+
type=float, default=None)
722725

723726
# Qeexo V2 CSV
724727
parser_qeexo_v2_csv = subparsers.add_parser("qeexo_v2_csv",
@@ -775,6 +778,8 @@ def main():
775778
sys.exit(1)
776779

777780
args = parser.parse_args()
781+
if args.convert_format == "simple_csv":
782+
args.convert_format = "csv"
778783

779784
if not isinstance(args.in_file, list):
780785
args.in_file = [args.in_file]
@@ -836,20 +841,20 @@ def main():
836841
if args.interval == 0:
837842
sys.exit(f"Invalid interval option: {args.interval} ms")
838843
write_SDS_QeexoV2CSV(args, data, meta_data)
839-
elif args.convert_format == "simple_csv":
844+
elif args.convert_format == "csv":
840845
# Only used for one sensor
841846
if (len(args.yaml) > 1) or (len(sds_files) > 1):
842-
sys.exit("Simple CSV file format only supports 1 metadata and 1 SDS file")
843-
requireValueMetadata(meta_data[sensor_name[0]], "Simple CSV")
847+
sys.exit("CSV file format only supports 1 metadata and 1 SDS file")
848+
requireValueMetadata(meta_data[sensor_name[0]], "CSV")
844849
createCSV(filename)
845850
write_SDS_SimpleCSV(args, data[sensor_name[0]], meta_data[sensor_name[0]])
846851
else:
847852
readCSV(filename)
848853

849854
if args.convert_format == "qeexo_v2_csv":
850855
write_QeexoV2CSV_SDS(args.sds_index)
851-
elif args.convert_format == "simple_csv":
852-
sys.exit('Simple CSV to SDS conversion is not supported.')
856+
elif args.convert_format == "csv":
857+
sys.exit('CSV to SDS conversion is not supported.')
853858

854859
# WAV
855860
elif "wav" in args.convert_format:

0 commit comments

Comments
 (0)