-
Notifications
You must be signed in to change notification settings - Fork 246
feat: Add std.parseCsv and std.manifestCsv #701
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
builtins.go
Outdated
} | ||
|
||
if row == 0 { // consider first row as header | ||
keys = record |
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.
I suppose we might make this a user option in future... No need to do it now though.
builtins.go
Outdated
for _, k := range record { | ||
keyCount[k]++ | ||
if c := keyCount[k]; c > 1 { | ||
keys = append(keys, fmt.Sprintf("%s__%d", k, c-1)) |
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.
I think this is actually going to be confusing because it's not going to round-trip back through the manifest function (the mangled column names will appear in the output). Also the behaviour would have to be documented which would be a pain. Now you've renamed the function and it doesn't look like a generic CSV reader anymore I think what you were originally doing was fine.
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.
I guess we can add an argument called handle_duplicate_headers=false
for users to opt for this. Using this flag, we could either overwrite the duplicate headers or rename the duplicate fields as above. WDYT?
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.
SGTM
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.
Made the changes
Hi @sparkprime |
@sparkprime nudging this PR |
Implement
std.parseCsv
andstd.manifestCsv
in standard librarycpp-jsonnet PR: google/jsonnet#1088