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

Allow multiline filter expression with comments #457

Open
nichtich opened this issue Jun 13, 2022 · 8 comments
Open

Allow multiline filter expression with comments #457

nichtich opened this issue Jun 13, 2022 · 8 comments
Labels
A-filter Area: The filter command backlog Backlog items C-enhancement Category: enhancement P-low Priority: low
Milestone

Comments

@nichtich
Copy link
Contributor

nichtich commented Jun 13, 2022

I'd like to filter records by multiple conditions, and document the filter expression with comments. For this it would be useful to allow line breaks as whitespace in filter expressions and to allow comments (e.g. from # to the end of line). An example:

[email protected] !~ '^a' &&   # kein Mailbox-Satz
!024O?              # nicht gelöscht

Given this feature, filters can be collected in files:

pica filter "$(< filter.txt )" sample.dat
@nichtich nichtich changed the title Allo multiline filter expression with comments Allow multiline filter expression with comments Jun 13, 2022
@nwagner84
Copy link
Member

Thanks for your request!

It's already possible to get a (complex) filter expression from a file (use -f or --file parameter), but a "dummy" filter expression is still necessary:

$ pica filter -f filter.txt "003@?" sample.dat

The file content can contain whitespace-, tab- or newline-characters, but no comments.

I'll implement the comment part soon!

@nwagner84 nwagner84 self-assigned this Jun 13, 2022
@nwagner84 nwagner84 added the C-enhancement Category: enhancement label Jun 13, 2022
@nichtich
Copy link
Contributor Author

but a "dummy" filter expression is still necessary

That's confusing. It it possible to set a default filter matching any field in this case?

@nwagner84
Copy link
Member

Actually, the filter expression from the CLI interface is overwritten by the content of the file, but it's not possible to omit the "dummy" cli argument.

This is indeed confusing and I'll try to fix this issue soon.

@nichtich
Copy link
Contributor Author

Current workaround is to use $(sed 's/#.*//;s/ \+/ /g;' filter.txt | tr -d '\n') as filter argument.

@nwagner84 nwagner84 added C-filter backlog Backlog items and removed C-enhancement Category: enhancement labels Jan 30, 2023
@nwagner84
Copy link
Member

nwagner84 commented Jan 30, 2023

Just a short note about the workaround: I think this doesn't work with expressions containing values with an # and the cardinality operator:

...
#012A/*{ #0 > 0 && z in ["abc", "def", "x#y"] } >= 10 && # my comment
...

@nichtich
Copy link
Contributor Author

The complexity of this issue seems low but I cannot tell. If so, I'd welcome it included in #505 or one of the next releases.

@nwagner84
Copy link
Member

Yesterday, I started with the implementation. Will be included in the upcoming release 0.17.0.

nwagner84 added a commit that referenced this issue Jun 21, 2023
@nwagner84
Copy link
Member

Sorry, this is more challenging as expected. I started working on this feature, but I must move this to v0.18.0.

@nwagner84 nwagner84 removed the backlog Backlog items label Jun 30, 2023
@nwagner84 nwagner84 added backlog Backlog items and removed C-filter labels Sep 15, 2023
@nwagner84 nwagner84 added C-enhancement Category: enhancement A-filter Area: The filter command P-low Priority: low labels Sep 1, 2024
@nwagner84 nwagner84 removed their assignment Sep 1, 2024
@nwagner84 nwagner84 modified the milestones: v1.0.0, v1.1.0 Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-filter Area: The filter command backlog Backlog items C-enhancement Category: enhancement P-low Priority: low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants