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

More complicated example #61

Open
fdncred opened this issue Aug 23, 2020 · 0 comments
Open

More complicated example #61

fdncred opened this issue Aug 23, 2020 · 0 comments

Comments

@fdncred
Copy link
Contributor

fdncred commented Aug 23, 2020

How about a more complicated example blue button to show a little more power?

open samples/movies.csv | group-by Year | get "2010" | update "Worldwide Gross" { get 'Worldwide Gross' | str trim --char '$' | str to-decimal } | sort-by 'Worldwide Gross' | reverse | update 'Worldwide Gross' { get 'Worldwide Gross' | str from -d 2 | format "${$it}" }

I wish we could write it with comments like:

open samples/movies.csv     # open the file as a csv
| group-by Year             # group the data by Year
| get "2010"                # get only the column labeled "2010"
| update "Worldwide Gross"  # update the Worldwide Gross column
{ get 'Worldwide Gross'     # get the Worldwide Gross column
| str trim --char '$'       # remove the $ character
| str to-decimal }          # convert the string numbers to actual decimal numbers
| sort-by 'Worldwide Gross' # sort by these newly created decimal numbers in the Worldwide Gross column
| reverse                   # reverse the order putting the largest numbers at the top
| update 'Worldwide Gross'  # update/overwrite the Worldwide Gross column again
{ get 'Worldwide Gross'     # get the data from the Worldwide Gross column
| str from -d 2             # convert the decimals to strings with 2 decimal places
| format "${$it}" }         # expand $it with the format command to add the $ back again
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

1 participant