Last active
March 13, 2019 21:16
-
-
Save t3rmin4t0r/c206799f8d33eeaf2b4c9bca38f253a2 to your computer and use it in GitHub Desktop.
Remove beeline pagination from a query result
This file contains hidden or 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
import sys | |
sample=""" | |
+------------------------------------------------------------------+--+ | |
| createtab_stmt | | |
+------------------------------------------------------------------+--+ | |
| CREATE TABLE `finance.xx_po_headers`( | | |
| `po_header_id` bigint, | | |
| `requester_name` string, | | |
+------------------------------------------------------------------+--+ | |
| createtab_stmt | | |
+------------------------------------------------------------------+--+ | |
| `enabled_flag` string, | | |
+------------------------------------------------------------------+--+ | |
""".split("\n") | |
def main(args): | |
lines = [x.strip() for x in open(args[0])] | |
NONE='NONE' | |
SEPARATOR1='SEPARATOR1' | |
HEADER='HEADER' | |
SEPARATOR2='SEPARATOR2' | |
ROW='ROW' | |
SEPARATOR3='SEPARATOR3' | |
state=NONE | |
for l in lines: | |
if not(l.strip()): | |
continue | |
sep = (l.startswith("+-")) | |
row = (l.startswith("|")) | |
nstate = None | |
if (state == NONE and sep): | |
nstate = SEPARATOR1 | |
elif (state == SEPARATOR3 and sep): | |
nstate = SEPARATOR1 | |
elif (state == SEPARATOR3 and row): | |
nstate = HEADER | |
elif (state == SEPARATOR1 and row): | |
nstate = HEADER | |
elif (state == HEADER and sep): | |
nstate = SEPARATOR2 | |
elif (state == SEPARATOR2 and row): | |
nstate = ROW | |
elif (state == ROW and sep): | |
nstate = SEPARATOR3 | |
elif (state == ROW and row): | |
nstate = ROW | |
if not(nstate): | |
print l | |
assert nstate != None | |
if (nstate == ROW): | |
print l[2:-2].rstrip() | |
pass | |
#print "%s -> %s" % (state, nstate) | |
state = nstate | |
if __name__ == "__main__": | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment