natural.data

natural.data.hexdump(stream)

Display stream contents in hexadecimal and ASCII format. The stream specified must either be a file-like object that supports the read method to receive bytes, or it can be a string.

To dump a file:

>>> hexdump(file(filename))     

Or to dump stdin:

>>> import sys
>>> hexdump(sys.stdin)          
Parameters:stream – stream input
natural.data.printable(sequence)

Return a printable string from the input sequence

Parameters:sequence – byte or string sequence
>>> print(printable('\x1b[1;34mtest\x1b[0m'))
.[1;34mtest.[0m
>>> printable('\x00\x01\x02\x03\x04\x05\x06\x06') == '........'
True
>>> print(printable('12345678'))
12345678
>>> print(printable('testing\n'))
testing.
natural.data.sparkline(data)

Return a spark line for the given data set.

Value data:sequence of numeric values
>>> print sparkline([1, 2, 3, 4, 5, 6, 5, 4, 3, 1, 5, 6])  
▁▂▃▄▅▆▅▄▃▁▅▆
natural.data.throughput(sample, window=1, format=u'decimal')

Return the throughput in (intelli)bytes per second.

Parameters:
>>> print(throughput(123456, 42))
2.87 kB/s