-
Notifications
You must be signed in to change notification settings - Fork 217
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
feature request: cat --filename
with optional argument to trim extensions etc from filenames
#1356
Comments
Hi @janxkoci ,
in some way I think you already have it. I try to explain myself with an example. Using
you get In Miller, using
you get
And you can also use your system commands. In Linux you can use in example
And you get
|
Ciao @aborruso, yes I know I can use The thing is that I've spent time fiddling with regexes and capturing, but after a good half hour it stops being fun, so I opened the CSV in sublime-text and fixed the format in 3 seconds. But I'd like to eventually automate this. And if you open the link and see how simple the usage could be for these basic cases - why not have it? 🙂 PS: the reason I don't just use |
@janxkoci this is spot-on -- a general theme of Miller is offering the flexibility to do whatever in the DSL, and then also for certain oft-occurring patterns, to package those up in a low-keystroking verb. This is a great idea! :) |
Sure, and you can desire whatever you like and which is comfortable for you. In your example you say And I agree it's better to use awk and miller, to search and replace by field. That said, I'm sure I don't understand your suggestion. But as always, @johnkerl understood it |
Exactly @johnkerl - having the power is nice, but as is mentioned in the link, most uses for @aborruso Fair enough, here is the important part from the usage function in the code: PS: sorry I missed this:
Here the |
cat --filename
with optional argument to trim extensions etc from filenames
I think it looks great 😃👍 |
And thanks so much 😁 |
My pleasure! :) |
The
cat --filename
parameter is very useful and I use it all the time now as I work on summarizing information from many files.But I noticed I often want to remove parts of the filename afterwards, especially the file extension(s) or subdirectory paths. This often involves passing through
put
and using thegsub()
et al functions, or even deeper dives to the DSL. I kinda wish there was a moresed
-like way to do this, and two approaches come to mind:sed
-like functionality to do quick find-and-replace operations on data column. Something likereplace "old,new" -f filename
would be enough for many use-cases, especially if you allow e.g."unwanted,"
(i.e. empty replacement string to delete stuff). Could also support regex for extra power.cat --filename "string"
that trims the"string"
from values in the filename column. Again, could support regex for extra power.The first approach is more generic and can be used on any column, while the second approach is probably easier to design, implement, and maybe even use, and covers the main use case I have in mind. Of course, nothing stops you from doing both 😉
As always, thanks for considering this feature and extra huge thanks for making such an amazing tool and sharing it with the world! 🤩
PS: don't pay too much attention to the code in the link - it shows quite a bizarre way to implement the "find-and-replace" functionality using just a
print
statement. Rather, I meant to show how simple the required functionality could be.The text was updated successfully, but these errors were encountered: