2018-11-26 方便的把文件读取到excel

开始

Excel可以读取csv文件,所以我们把文件换成csv文件就可以方便的换成Excel了,而且如果知道操作Excel那就更好了,但是没找到py操作Excle的东西
直接贴代码
···

!D:\My Python\Trans_to_txt.py

注意Windows下路径表示

'''
we store the filename to the newfilename.txt
'''
import os
import docx

print('Enter your Director's path:')
mypath='F:\vscode\.vscode\python\python课\文件操作\英文分词\data\真题'
all_FileNum = 0

def Translate(level, path):
global all_FileNum
'''
将一个目录下所有doc文件转成txt
'''
ff = open("F:\vscode\.vscode\python\python课\文件操作\英文分词\data\newfilename.txt",'a+')
#该目录下所有文件的名字
files = os.listdir(path)# get the file name in the doc......
for f in files:
if '真' in f:
print(f)
ff.writelines(f+'\n')
# finalpath = path+'\'+f
#storepath = finalpath.replace(".docx",".txt")
# os.mknod(storepath)
# ss = open(storepath,"a+")
# context = docx.Document(finalpath)

        # for par in context.paragraphs:
        #     ss.writelines(par.text)
        #     # #print(par.text)
        #     # print("  ")
        
    else:
        continue

if name == 'main':
Translate(1, mypath)

···

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,507评论 0 13
  • # Awesome Python [![Awesome](https://cdn.rawgit.com/sindr...
    emily_007阅读 2,227评论 0 3
  • 1.创建文件夹 !/bin/sh mkdir -m 777 "%%1" 2.创建文件 !/bin/sh touch...
    BigJeffWang阅读 10,193评论 3 53
  • 个人学习批处理的初衷来源于实际工作;在某个迭代版本有个BS(安卓手游模拟器)大需求,从而在测试过程中就重复涉及到...
    Luckykailiu阅读 4,782评论 0 11
  • 我喜欢诗 我也尝试着写诗 可没有李杜的才气 没有忧国忧民的情怀 没有边塞文人的风花雪月 更没有润之的磅礴大气 可我...
    似冰的梦阅读 128评论 2 1