Add to_csv/read_csv support for RegularTimeSeries - #115
Conversation
ktarbet
left a comment
There was a problem hiding this comment.
I think we should consider a ISO format for output, and add timezone like the units are handled. But still support reading legacy formats.
| roll_day = False | ||
| # try seconds format first, then minute format | ||
| time = None | ||
| for fmt in ("%d%b%Y %H%M%S", "%d%b%Y %H%M"): |
There was a problem hiding this comment.
Consider checking the length of the time string, then you shoud dnot need try/except, and may be better for error control. If we default to ISO we will also need to read that format. perhaps wtih time-zone in each time-stamp.
| for i in range(len(metadata_rows)): | ||
| row = metadata_rows[i] | ||
| metadata_value = id_components[i] | ||
| if row == 'D': # Skip D by convention |
There was a problem hiding this comment.
There is a special case where Dpart can be 'ts-pattern' We should keep that one for export, but worth checking if that is also in issue in DSSVue?
| value = float(val_str) if val_str else 0.0 | ||
| times.append(time) | ||
| values.append(value) | ||
| if has_quality and len(row) >= 4: |
There was a problem hiding this comment.
If you expect quality array, but don't have data, add a zero quality for that row instead of skipping.
regular_timeseries.py:
to_csv()method that exports theRegularTimeSeriesdata to a .csv file tofile_pathwith the option to include metadata (id, path).read_csv()static method that reads in a csv atfile_pathand returns aRegularTimeSeriesobject.test_csv.py.