Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 85: validate & format datetime in xlsx job template #87

Merged
merged 4 commits into from
Apr 4, 2024

Conversation

helen-m-lin
Copy link
Contributor

closes #85

  • Add data validator for acq_datetime column to check input is valid date
  • Enforce excel to format and save dates in ISO datetime format (yyyy-mm-dd hh:mm:ss)
  • Update unit tests and add new test for files with empty rows (Excel saves formatted blank cells as empty rows)

@helen-m-lin helen-m-lin requested a review from jtyoung84 April 3, 2024 17:43
@@ -16,6 +16,7 @@ class JobUploadTemplate:

FILE_NAME = "job_upload_template.xlsx"
NUM_TEMPLATE_ROWS = 20
XLSX_DATETIME_FORMAT = "yyyy-mm-dd hh:mm:ss"
Copy link
Contributor

@jtyoung84 jtyoung84 Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISO format is typically represented at YYYY-MM-DDTHH:mm:ss although I'm not sure how excel does it

Copy link
Contributor Author

@helen-m-lin helen-m-lin Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both work in excel as custom formats and pass the regex check from BasicUploadJobConfigs._DATETIME_PATTERN1

I tried to match the ValueError raised in BasicUploadJobConfigs._parse_datetime and what we have in the sample csvs, but I'm happy to change it to YYYY-MM-DDTHH:mm:ss instead. What do you think?

raise ValueError(
"Incorrect datetime format, should be"
" YYYY-MM-DD HH:mm:ss or MM/DD/YYYY I:MM:SS P"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should handle both the space and the 'T' but use the YYYY-MM-DDTHH:mm:ss for the XLSX_DATETIME_FORMAT if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@jtyoung84 jtyoung84 merged commit ef1e362 into main Apr 4, 2024
3 checks passed
@jtyoung84 jtyoung84 deleted the feat-85-xlsx-datetime branch April 4, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support datetime format xlsx uses
2 participants