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

Filter fails when pipe separated file header columns names include "." or "-" #1161

Closed
oPromessa opened this issue Dec 28, 2022 · 2 comments
Closed

Comments

@oPromessa
Copy link

oPromessa commented Dec 28, 2022

Hi there. Great tool! Excellent JOB!

I have a small issue. MLR is not able to filter a pipe separated file where the column titles include a ".". Also tried replacing "." with "-" with the same result. It works if I remove the "." (dot) from the heading column names.

Maybe I'm doing something wrong ;)

$ cat origin.csv
1.Directory|2.FileName|19.Duration
.|IMG_20221105_194421.HEIC|-
.|IMG_20221105_194428.HEIC|-
.|IMG_20221105_194732.HEIC|0
.|IMG_20221105_194733.HEIC|0
.|IMG_20221105_203107.HEIC|90
.|IMG_20221105_203108.HEIC|90
.|IMG_20221105_203109.HEIC|120
.|IMG_20221105_203110.HEIC|120
.|IMG_20221105_205105.HEIC|120

$  mlr --csv --fs pipe cut -f 2.FileName,19.Duration then filter '$19.Duration == "0"' origin.csv 

$  mlr --csv --fs pipe cut -f 2.FileName,19.Duration  origin.csv 
2.FileName|19.Duration
IMG_20221105_194421.HEIC|-
IMG_20221105_194428.HEIC|-
IMG_20221105_194732.HEIC|0
IMG_20221105_194733.HEIC|0
IMG_20221105_203107.HEIC|90
IMG_20221105_203108.HEIC|90
IMG_20221105_203109.HEIC|120
IMG_20221105_203110.HEIC|120
IMG_20221105_205105.HEIC|120

$ cp origin.csv corrected.csv
$ vi corrected.csv 
$ cat corrected.csv 
1.Directory|2.FileName|19Duration
.|IMG_20221105_194421.HEIC|-
.|IMG_20221105_194428.HEIC|-
.|IMG_20221105_194732.HEIC|0
.|IMG_20221105_194733.HEIC|0
.|IMG_20221105_203107.HEIC|90
.|IMG_20221105_203108.HEIC|90
.|IMG_20221105_203109.HEIC|120
.|IMG_20221105_203110.HEIC|120
.|IMG_20221105_205105.HEIC|120

$ mlr --csv --fs pipe cut -f 2.FileName,19Duration then filter '$19Duration == "0"' corrected.csv 
2.FileName|19Duration
IMG_20221105_194732.HEIC|0
IMG_20221105_194733.HEIC|0
@aborruso
Copy link
Contributor

Hi @oPromessa when you have special char, you must use "{}".

mlr --csv --fs pipe cut -f 2.FileName,19.Duration then filter '${19.Duration} == "0"' input.csv

@oPromessa
Copy link
Author

Thanks @aborruso for the quick response! Worked like a charm!

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

No branches or pull requests

2 participants