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

[Miller] cerca e sostituisci in un campo #146

Closed
pigreco opened this issue May 6, 2020 · 3 comments
Closed

[Miller] cerca e sostituisci in un campo #146

pigreco opened this issue May 6, 2020 · 3 comments

Comments

@pigreco
Copy link
Contributor

pigreco commented May 6, 2020

Ho un file csv con alcuni campi e vorrei pulire un campo specifico (tags) da testo indesiderato:

  • ; iniziali e finali
  • Feature
  • Needs Documentation
  • backport release-3_10
  • backport release-3_12
  • Squash!
  • Requires Tests!
  • Changelog

da ricerche sul web ho trovato questo ma non so come usarlo.

mlr --csv $tags=gsub($tags, "Feature", "") merge_mod.csv >test1.csv

mi dice che è errato: -bash: syntax error near unexpected token ('`

allego file csv

merge_mod.txt

@aborruso
Copy link
Member

aborruso commented May 6, 2020

Puoi usare il verbo put e la fuzione gsub, che fa un trova e sostituisci globale usando regex in standard posix.2

Qui sotto un esempio con due trova e sostituisci, separati da ;.

mlr --csv put '$tags=gsub($tags,"Needs Documentation","");$tags=gsub($tags,"Feature","")' input >output

@pigreco
Copy link
Contributor Author

pigreco commented May 6, 2020

caro @aborruso funziona tutto.

ho usato lo scriptino di sotto, ma rimane qualche ; di fine riga che non riesco a eliminare, per il rsto tutto ok

mlr --csv put '$tags=gsub($tags,"^(; ){1,}",""); $tags=gsub($tags,"(; ){1,}$","");$tags=gsub($tags,".?Needs Documentation.?",""); $tags=gsub($tags,".?Feature.?",""); $tags=gsub($tags,".?Squash!.?","");$tags=gsub($tags,".?Requires Tests!.?","");$tags=gsub($tags,".?Changelog.?",""); $tags=gsub($tags,".?backport release-3_1..?","")' merge_mod.csv | vd -f csv

grazie

@pigreco pigreco closed this as completed May 6, 2020
@pigreco pigreco reopened this May 6, 2020
@pigreco
Copy link
Contributor Author

pigreco commented May 6, 2020

@pigreco pigreco closed this as completed May 6, 2020
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