processing csv with python

 I need to extract out data from wireshark captured data. And I already extracted out these collected data about a specific IP. And the final data that I need is about rtt. And the some lines on the rtt data is null value and I tried it with Excel to filter out these lines with CTRL+G operation. The excel works slowly and some times was stuck without any response.
 The format of my data is the following:

Time,Source,Destination,rtt,destport,srcport
2.679784,10.0.4.1,10.0.5.2,,3333,35852
2.71042,10.0.4.1,10.0.5.2,,3333,35854
2.823876,10.0.5.2,10.0.4.1,0.144092,35852,3333
2.840817,10.0.5.2,10.0.4.1,0.130397,35854,3333
2.854966,10.0.4.1,10.0.5.2,0.03109,3333,35852
2.866116,10.0.4.1,10.0.5.2,,3333,35852
2.866121,10.0.4.1,10.0.5.2,,3333,35852
2.866209,10.0.4.1,10.0.5.2,,3333,35852
2.866211,10.0.4.1,10.0.5.2,,3333,35852

 So finally, I get the problem solved with python. Here is my code.
data_processing_csv.py:

#!/usr/bin/env python
import csv

filename = 'in.csv'
data_out="out.txt"
fileObject = open(data_out, 'w')
with open(filename) as f:
    reader = csv.reader(f)
    for row in reader:
        if(row[3]!=""):
            for i in range(len(row)):
                fileObject.write(row[i])
                fileObject.write("\t")
            fileObject.write("\n")

[1]‘module’ object has no attribute ‘reader’

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值