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
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: