python tab_to_csv.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python tab_to_csv.py相关的知识,希望对你有一定的参考价值。

import os

# set directory to Desktop
os.chdir("C:/Users/" + os.environ.get("USERNAME") + "/Desktop")

print "Enter name of TAB separated file. Make sure"
print "that it's located in the Desktop"
tab_file = raw_input("=> ")

print "Give a name to the CSV file to be created"
print "(Use .csv extension)"
comma_file = raw_input("=> ")

file_1 = open(tab_file, "r")
file_2 = open(comma_file, "w")

for line in file_1:
    file_2.write(line.replace('\t', ','))

file_1.close()
file_2.close()

print "All done!"
quit()

以上是关于python tab_to_csv.py的主要内容,如果未能解决你的问题,请参考以下文章

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python