Skip to content

Instantly share code, notes, and snippets.

@Jongbhin
Created February 7, 2020 05:40
Show Gist options
  • Save Jongbhin/8da62d7647714b9603144191ecece224 to your computer and use it in GitHub Desktop.
Save Jongbhin/8da62d7647714b9603144191ecece224 to your computer and use it in GitHub Desktop.
[tsv to csv] #tsv #csv
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import csv
output_dir = ''
input_file = os.path.join(output_dir, 'input0000')
output_file = os.path.join(output_dir, 'input0000.tsv')
def main():
with open(input_file) as ifd, open(output_file, mode='w') as ofd:
csv_reader = csv.reader(ifd, delimiter='\t', quoting=csv.QUOTE_NONE)
csv_writer = csv.writer(ofd, delimiter=',')
for counter, row in enumerate(csv_reader):
csv_writer.writerow(row)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment