-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support reading from gzipped files #17
base: main
Are you sure you want to change the base?
Conversation
@Myles1 Thank you so much for your pull request and your patience. I think this definitely makes sense and is a value-add. The one thing that I would request to be changed is to avoid adding the Once updated we'll gladly accept this PR with much thanks! |
@@ -10,7 +11,7 @@ import { | |||
import { ValidationResult } from "hpt-validator/src/types" | |||
import { InvalidArgumentError } from "commander" | |||
|
|||
type FileFormat = "csv" | "json" | |||
type FileFormat = "csv" | "json" | "json.gz" | "csv.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove .gz
extensions as acceptable format types.
const fileExt = path.extname(filepath).toLowerCase().replace(".", "") | ||
if (["csv", "json"].includes(fileExt)) { | ||
return fileExt as FileFormat | ||
const isGzipped = path.extname(filepath).toLowerCase() === ".gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially hoist this check up to determine if one of the acceptable formats is gzipped.
@@ -14,7 +14,9 @@ async function main() { | |||
.addOption( | |||
new Option("-f, --format <string>", "file format of file").choices([ | |||
"csv", | |||
"csv.gz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these new options as acceptable formats as the main branch of logic would handle this internally.
Thanks for publishing and maintaining this project. Super helpful stuff!
Feel free to just close this PR if you don't want it. No biggie either way :)
One line description of your change (less than 72 characters)
Support reading from
.csv.gz
and.json.gz
files.Problem
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of being the motivation for your change.
I'm compressing the data files locally and need to unzip them before I can run the
hpt-validator-cli
. This just lets us read gzipped files directly.Solution
Describe the modifications you've done.
Allow reading directly from gzipped data files.
Test Plan
(Write your test plan here. If you changed any code, please provide us with
clear instructions on how you verified your changes work.)
Create a gzipped data file
$gzip my_file.json
You should now have a file named
my_file.json.gz
Run
hpt-validator-cli
on that new file.Ensure the results are the same as they were on the unzipped file.