#!/usr/bin/env python

import argparse
import sys


def _lines(stream):
    l = stream.readline()
    while l != "":
        yield l
        l = stream.readline()


def main(argv):
    parser = argparse.ArgumentParser(
        description=("Add a value in every line so that you add a column in "
                     "tabular data")
    )

    parser.add_argument(
        "value",
        help="Which value to add"
    )

    parser.add_argument(
        "--prepend",
        action="store_true",
        help="Add the value as the first column instead of as the last"
    )
    parser.add_argument(
        "--header",
        default=None,
        help="Use this value as header for the column"
    )
    parser.add_argument(
        "--delimiter", "-d",
        default=" ",
        help="Use this delimiter to separate the columns"
    )
    parser.add_argument(
        "--increment",
        default=0.0,
        type=float,
        help="Add this value to the initial"
    )
    parser.add_argument(
        "--no_flush",
        dest="flush",
        action="store_false",
        help="Do not flush after every line"
    )

    args = parser.parse_args(argv)

    v = args.value
    for i, line in enumerate(_lines(sys.stdin)):
        if i == 0 and args.header:
            v = args.header
        if args.prepend:
            print v + args.delimiter + line.strip()
        else:
            print line.strip() + args.delimiter + v
        if args.flush:
            sys.stdout.flush()
        if args.increment != 0:
            try:
                v = str(float(v) + args.increment)
            except ValueError:
                pass


if __name__ == "__main__":
    main(sys.argv[1:])
