python对csv文件取特定列生成新csv文件

import csv
import os

def file_name(in_file,out_file):
    reader = csv.reader(in_file)
    header = next(reader)
    # data_header = ("{},{}".format(header[5],header[9]))
    # print(data_header)
    writer = csv.writer(out_file)
    writer.writerow([header[5],header[9]])
    for row in reader:
        # data_header = ("{} {}" .format(row[5],row[9]))
        # print(data_header)
        writer.writerow([row[5] , row[9]])
        # data_row = csv.writer(data_header)
        # out_file.write(data_row)
    in_file.close()
    out_file.close()

in_file  = open("iladata.csv", mode="r", encoding="utf-8")
out_file = open("data_pll_lock_out.csv", mode="w", newline='')
out_file1 = open("data_pll_clock_out.csv", mode="w", newline='')
out_file2 = open("data_pll_tdo_out.csv", mode="w", newline='')

file_name(in_file,out_file)

主要参考目录:

https://blog.csdn.net/qq_44033208/article/details/121325373?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166504462716800182739539%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=166504462716800182739539&biz_id=&utm_medium=distribute.pc_search_result.none-task-code-2~all~first_rank_ecpm_v1~rank_v31_ecpm-2-121325373-0-null-null.142%5Ev51%5Econtrol,201%5Ev3%5Eadd_ask&utm_term=Python%20Excel%E5%8F%96%E9%83%A8%E5%88%86%E5%88%97%E7%94%9F%E6%88%90TxT%E6%96%87%E4%BB%B6

python中import pandas用法:

https://blog.csdn.net/CSDNhuaong/article/details/80510791

python中对于csv文件的处理:

https://blog.csdn.net/bryanwang_3099/article/details/119731390

python中对于文件中的数字进行运算并求和:

https://blog.csdn.net/weixin_43327597/article/details/114555229

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值