#CSV Python project

8 messages · Page 1 of 1 (latest)

obsidian python
#

this is my code
i want it to search in excel and update it to what user says

import csv
f=open('ayo.csv','r')
s=input('enter line: ')
n=input('enter no.: ')
fn=csv.reader(f)
for i in fn:
    if i[0]==s:
        print(i)
        for j in i:
            print(j[-1])
            if j[-1]==n:
                print(j[-1])```

but its not working after the if part
short sentinel
#

It's not clear from what you've shared what isn't working correctly.

Try adding a print before the if that prints out each item the if is checking. For example

print(f"{i[0]=}, {s=}")
obsidian python
#

When I print it it’s printing what I want
But there is something wrong with last if statement

#

currently the output of that code is this

#

if i want to search b3
i want to first search the row in which b3 is and then search b3 and print it

short sentinel
#

Is the code you shared exactly the same code that you ran to get that screenshot?

obsidian python
#

yes