view tsv.py @ 5:0e8079ac24f8 draft default tip

planemo upload commit f33bdf952d796c5d7a240b132af3c4cbd102decc
author cpt
date Fri, 05 Jan 2024 05:51:54 +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])