File: diff-to-bytes-output

package info (click to toggle)
zeekctl 2.2.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,544 kB
  • sloc: python: 5,639; sh: 1,374; makefile: 71; awk: 24
file content (25 lines) | stat: -rwxr-xr-x 558 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /usr/bin/env python
#
# Convert large integers in the to-bytes.awk output to floating point
# exponential format, because some versions of awk output large integers in
# that format.

from __future__ import print_function
import sys

bignumber = 2**31-1

for line in sys.stdin:
    outstr = ""
    for field in line.split():
        try:
            num = float(field)
        except ValueError:
            num = 0

        if num > bignumber:
            outstr += "%.5e " % num
        else:
            outstr += "%s " % field

    print(outstr[:-1])