Created
March 25, 2015 18:16
-
-
Save bruab/506e9f7f61af16dd844c to your computer and use it in GitHub Desktop.
Let's take a tab-delimited file and replace its first column with nine spaces. Let's do this ... to all tab-delimited files.
This file contains 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
#!/usr/bin/env python3 | |
import sys | |
# Check command line arg | |
if len(sys.argv) != 2: | |
sys.stderr.write("usage: replace_first_column_with_nine_spaces.py <input.tsv>\n") | |
sys.exit() | |
# Open file | |
with open(sys.argv[1], 'r') as infile: | |
for line in infile: | |
fields = line.split("\t") | |
fields[0] = " " # 9 spaces y'all | |
sys.stdout.write("\t".join(fields)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment