Open srrmlwn opened 8 years ago
I confirm, I have the same problem. It does not work with single json (json with only one record).
For the moment I have a little workaround. I'm working very rarely with AWK, so may be it's not very correct/good solution, but for the moment it works for me.
It seems that the problem is in the line 99 of jsonv file.
count=$(cat $tokens | sed 's/^[\["a-z,]*//g' | sed 's/,.*//g' | gawk '/^[0-9]+$/ && !_[$0]++' | gawk -F\t 'BEGIN{max==""} ($1 > max) {max=$1} END{print max}')
BEGIN{max==""} ($1 > max)
does not work if $1 is equal to 0.
I changed it for
count=$(cat $tokens | sed 's/^[\["a-z,]*//g' | sed 's/,.*//g' | gawk '/^[0-9]+$/ && !_[$0]++' | gawk -F\t 'BEGIN{max=0} ($1 > max) {max=$1} END{print max}')
and it works with single json file. Hope it will be corrected properly by maintainer.
@paulz1 your change seems to work correctly. I'd suggest submitting a pull request.
Thanks for this super helpful script!
I did realize however, a simple json with just one element such as the below doesn't return any output.
Can this be checked please?
Thanks.