Skip to content

Instantly share code, notes, and snippets.

@samuell
Last active December 28, 2015 03:39
Show Gist options
  • Select an option

  • Save samuell/7436526 to your computer and use it in GitHub Desktop.

Select an option

Save samuell/7436526 to your computer and use it in GitHub Desktop.
Example showing how to manipulate tab separated data on the standard input, and write the manipulated data to standard output.
import csv
from sys import stdin, stdout
tsv_in = csv.reader(stdin, delimiter="\t")
tsv_out = csv.writer(stdout, delimiter="\t")
for row in tsv_in:
# Write out only columns 2-*
tsv_out.writerow(row[1:])
@samuell

samuell commented Nov 12, 2013

Copy link
Copy Markdown
Author

To be executed like this:

cat some_tab_separated_data.tsv|python stream_editing_tsv.py|less

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment