Created
February 7, 2020 05:40
-
-
Save Jongbhin/8da62d7647714b9603144191ecece224 to your computer and use it in GitHub Desktop.
[tsv to csv] #tsv #csv
This file contains hidden or 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
# -*- 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