I am doing a python project.I opened a new csv files and its contents are
A | B
-------------
1. 200 | 201
2. 200 | 202
3. 200 | 201
4. 200 | 203
5. 201 | 201
6. 201 | 202
...........
And what I am doing is...
def csvvalidation(readers):
for row in readers:
print row
def checkduplicationcsv(reader):
datalist = []
for row in reader:
print row
content = list(row[i] for i in range(0,3))
datalist.append(content)
with open("new.csv", "rb") as infile:
reader = csv.reader(infile)
first_row = next(reader, None) # skip the headers
checkduplicationcsv(reader)
csvvalidation(reader)
The problem is I can print the values only one time.The csvvalidation()
function reader is not working.How can I use the reader object multiple times.I can't print its row values.What can I do?Please give me a solution.And I am not aware of seek()
(I think that its pointing to the same reader again).So I tried infile.seek(0)
after the first function but no use.nothing happens
Thanks in advance.