From d06519f3eb657a05c2c5c628a073d31e49400e5a Mon Sep 17 00:00:00 2001 From: rubenszinho Date: Thu, 17 Apr 2025 00:02:56 -0300 Subject: [PATCH 1/2] fix: correct data format parsing and make start time parameter required --- README.md | 127 +++++---------------- cmd/analyze-csv/main.go | 159 +++++++++++++++++++++++++++ cmd/enemeter-data-processing/main.go | 9 +- internal/commands/process.go | 150 +++++++++++++++++++------ internal/metrics/energy_calc.go | 10 +- internal/parser/csv_parser.go | 65 +++++++---- 6 files changed, 352 insertions(+), 168 deletions(-) create mode 100644 cmd/analyze-csv/main.go diff --git a/README.md b/README.md index 9fe789b..7014a7e 100644 --- a/README.md +++ b/README.md @@ -42,42 +42,31 @@ cd enemeter-data-processing make build ``` -## Data Format - -ENEMETER data is provided in CSV format with four columns: - -1. **Time Delta (milliseconds)** - Time elapsed since the last measurement -2. **Temperature (millicelsius)** - System temperature -3. **Voltage (microvolts)** - Battery voltage -4. **Current (nanoamperes)** - System current (positive when charging, negative when discharging) - -Example: -``` -0000052051,0004815430,-1275169536,0000023192 -0000000047,0004815430,-1275169536,0000023192 -0000000047,0004815790,-1276443264,0000023192 -``` - ## Basic Usage -Process a CSV file with default settings: +Process a CSV file with required parameters: ```bash -./enemeter-data-processing --input=data/data.csv +./enemeter-data-processing process --input=data/esp32.csv --start="2023-04-01 08:00:00" ``` +The `--start` parameter specifies the starting time of the measurements and is required. +**Important:** You must include both the date AND time of day in the format "YYYY-MM-DD HH:MM:SS". + Save results to a text file: ```bash -./enemeter-data-processing --input=data/data.csv --output=report.txt +./enemeter-data-processing process --input=data/esp32.csv --start="2023-04-01 08:00:00" --output=esp32_report.txt ``` ## Command-line Options -### Input/Output Options +### Required Parameters +- `--input=`: Path to the input CSV file +- `--start=