0% found this document useful (0 votes)
2K views3 pages

CSV User-ID and Password Management

The program aims to create a CSV file containing user IDs and passwords entered by the user. It defines functions to write data to the CSV file, read the entire CSV file, and search the CSV file to find and print the password associated with a given user ID. The write function prompts the user to enter a user ID and password and writes it to the CSV file. The read function opens and prints the CSV file. The search function prompts for a user ID, searches the CSV for a matching ID, and prints the associated password if found.

Uploaded by

kamalesh.g9a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views3 pages

CSV User-ID and Password Management

The program aims to create a CSV file containing user IDs and passwords entered by the user. It defines functions to write data to the CSV file, read the entire CSV file, and search the CSV file to find and print the password associated with a given user ID. The write function prompts the user to enter a user ID and password and writes it to the CSV file. The read function opens and prints the CSV file. The search function prompts for a user ID, searches the CSV for a matching ID, and prints the associated password if found.

Uploaded by

kamalesh.g9a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program 8

Aim:

To write a python program to create a CSV file by entering user-id and password , read and
search the password for given userid.

Algorithm:

1. Start
2. Create a csv file
3. Create a write () and write the user id and password.
4. Save the user-id and password in csv file by using writer method.
5. Read the csv file by using the read() .
6. Open the file in read mode and read the file by using the reader method.
7. Create a search() and search the password for the given user-id.
8. Print the password.
9. Stop.

Program:

import csv

def write():

print("Writing data into csv file:")

f=open("D:\\data\\[Link]","w",newline='')

swriter=[Link](f)

[Link](['userid','password'])

while True:

userid=input("Enter User ID:")

password=input("Enter your password:")

data=[userid,password]

[Link](data)

ch=input("Do you want to more records :(y/n)?")

if ch in "nN":
break

print("Data write in csv file successfully")

[Link]()

def read():

f=open("D:\\data\\[Link]","r")

print("Searching data from csv file")

print("____________")

sreader=[Link](f)

for i in sreader:

print(i)

def search():

while True:

f=open("D:\\data\\[Link]","r")

print("searching data from the file")

sreader=[Link](f)

s=input("Enter Userid to search:")

found=0

for i in sreader:

if(i[0]==s):

found=1

print(i[1])

break

if(found==0):

print("sorry no record found")

ch=input("Do yo wnat to search any more records:(y/n)")


if ch in "nN":

break

[Link]()

write()

read()

search()

Result:

Thus the above python program to create a CSV file by entering user-id and password , read and
search the password for given user-id was executed successfully and the output is verified.

You might also like