Skip to content

Instantly share code, notes, and snippets.

@Hirosaji
Created January 25, 2020 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hirosaji/7636384074d95f3e9068b6e169d69f6a to your computer and use it in GitHub Desktop.
Save Hirosaji/7636384074d95f3e9068b6e169d69f6a to your computer and use it in GitHub Desktop.
handle tsv data (ex. delete column)
import csv
import numpy as np
with open('test.tsv', mode='r', newline='', encoding='utf-8') as f:
raw_input = csv.reader(f, delimiter='\t')
input = [row for row in raw_input]
# handle data (ex. delete column)
output = np.delete(input, 1, 1)
with open('output.tsv', mode='w', newline='', encoding='utf-8') as fo:
tsv_writer = csv.writer(fo, delimiter='\t')
tsv_writer.writerows(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment