以合并csv文件中的两列 [英] to merge two columns in a csv file

查看:3137
本文介绍了以合并csv文件中的两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在csv文件中合并两列

merge two columns in a csv file

推荐答案

这里是一个例子,不知道你的分隔符。如果你想把它写到同一个文件,你必须先缓冲整个文件,修改行,然后写回同一个文件。

Here is an example, dont know your delimiter. if you want to write it to the same file you have to buffer the whole file first, modify the rows, then write it back to the same file.

 import csv
 for row in csv.reader(open('test.txt'),delimiter="\t"):
     print row[0]+row[1]

这篇关于以合并csv文件中的两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆