Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a
fill
subcommand. I'm not strongly opinionated about this being inxsv
, but I find it useful, so I thought I would make the PR and see.Motivation: I have CSVs (usually from DB dumps) with empty values in certain columns, which I want to fill forwards or backwards using the next valid value.
Implementation: Iterate through rows, gather and store the last valid value, and fill in missing values as they are found. The
--backfill
argument fills empty values which occur before the first missing value, and so must buffer.There is also a
--groupby
feature, something that XSV doesn't do very often, but which I find helpful in this case, to group by e.g. (in application logs)user_id
, if the filled value should only apply to each user, or byapp_version
if the value really applies to each app version. This does increase the memory overhead by the order of the number of groups.