Created
January 13, 2022 13:50
-
-
Save johnkerl/2e384baa62dd1090c056d833f55def8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat test.csv | |
x | |
5-18:53:20 | |
$ cat deslurm.mlr | |
func deslurm(str s): num { | |
# example "5-18:53:20" | |
t = splita(s, "-"); | |
u = splita(t[2], ":"); | |
days = t[1]; | |
hours = u[1]; | |
minutes = u[2]; | |
seconds = u[3]; | |
return seconds + minutes * 60 + hours * 3600 + days * 86400; | |
} | |
$ echo x=5-18:53:20 | mlr put -f deslurm.mlr -e '$y = deslurm($x)' -e '$z=sec2dhms($y)' | |
x=5-18:53:20,y=500000,z=5d18h53m20s | |
$ cat deslurm2.mlr | |
func deslurm(str s): num { | |
# example "5-18:53:20" | |
fields = unformat("{}-{}:{}:{}", s); | |
days = fields[1]; | |
hours = fields[2]; | |
minutes = fields[3]; | |
seconds = fields[4]; | |
return seconds + minutes * 60 + hours * 3600 + days * 86400; | |
} | |
$ echo x=5-18:53:20 | mlr put -f deslurm2.mlr -e '$y = deslurm($x)' -e '$z=sec2dhms($y)' | |
x=5-18:53:20,y=500000,z=5d18h53m20s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment