社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

prasanthG

prasanthG 最近回复了

万岁,我明白了,谢谢@Kushan Gunasekera

import csv
filename = "F:\\FairDealCustomerData.csv"
csvout = "F:\\FairDealCustomerDataout.csv"
with open(filename,'r',newline='') as read_file:
    readCSV = csv.reader(read_file, delimiter=',')
    with open(csvout,"w",newline='') as write_file:
        writer = csv.writer(write_file)
        for row in readCSV:
            writer.writerow([row[0], row[1].split('.')[1].strip() + ' ', row[2], 
            row[1].split('.')[0].strip()])
write_file.close()

ALERT:please do care about with and for functionalities other wise we will get 
 ValueError: I/O operation on closed file