view tsv.py @ 4:78ce8a1a8fd1 draft

planemo upload commit 852ac96ca53a2ffa0947e6df5e24671866b642f5
author cpt
date Sun, 23 Jul 2023 01:43:12 +0000
parents 134bb2d7cdfd
children
line wrap: on
line source

import sys


# Like 'import json' / 'import yaml', except.. tab data.
def loads(str_data):
    return NotImplementedError()


def load(handle):
    return NotImplementedError()


def dump(data, handle=sys.stdout):
    for row in data:
        handle.write("%s\n" % "\t".join(map(str, row)))


def dumps(data):
    output = ""
    for row in data:
        output += "%s\n" % "\t".join(map(str, row))
    return output


def dump_line(row, handle=sys.stdout):
    dump([row], handle=handle)


def dumps_line(row):
    return dumps([row])