query on csv file reading and replacing

muttu2244 at yahoo.com muttu2244 at yahoo.com
Fri Dec 23 22:07:19 CET 2005

Hi everybody

Am trying to read a csv file "temp.csv", which has the below info,

compName       macAddr                ipAddr

Chris-Dev	      0003469F44CC	Microsoft Windows XP
Shivayogi-Dev  000D5234F44C	Microsoft Windows XP
John-test	      000D123F44CC	Microsoft Windows XP
Professional Steve-Dev	      000D123F55CC	Microsoft
Windows XP Professional

am trying to read it in the following way--

>>> import csv
>>> infoFile = open ('c:\\temp.csv','r')
>>> rdr = csv.reader(infoFile)
>>> for row in rdr:
... 	if row[0] == infnList[0]:
... 		if not row[1] == infnList[1] or not row[2] == infnList[2]:

now am comparing my comp Name  with the "compName" fields, and if it
matches i ll then compare for the "mac address" and "ip address". if
they are not matching with my system, i have to modify them there
itself, i mean i have to update "mac address" and "ip address" in the
same row itself, i dont want to append the information with another row
to the "temp.csv" file. otherwise it will have two similar computer
names for two rows, which i dont want to happen.

please give me the ways how i can work on this.

thanks in advance

More information about the Python-list mailing list