0% found this document useful (0 votes)
23 views9 pages

Lab Discussion5: Programs Using Text, CSV Files: Jeya Pandian. M Apii/Cse Srinivasa Ramanujan Centre Sastra

The document discusses programs that use text and CSV files for various tasks. It includes programs that: 1) Sort and output comma-separated words from a text file alphabetically. 2) Count letters, digits, and symbols in sentences from a text file. 3) Validate passwords based on criteria and output valid ones. 4) Compute and output word frequencies from a text file. 5) Create and manipulate trip data stored in a CSV file. 6) Create and manipulate employee data stored in a CSV file, including listing, adding, deleting, and searching employees. 7) Create and manipulate student marks stored in a CSV file, including listing data, searching students, adding, fetching, and

Uploaded by

Lakshaya A
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)
23 views9 pages

Lab Discussion5: Programs Using Text, CSV Files: Jeya Pandian. M Apii/Cse Srinivasa Ramanujan Centre Sastra

The document discusses programs that use text and CSV files for various tasks. It includes programs that: 1) Sort and output comma-separated words from a text file alphabetically. 2) Count letters, digits, and symbols in sentences from a text file. 3) Validate passwords based on criteria and output valid ones. 4) Compute and output word frequencies from a text file. 5) Create and manipulate trip data stored in a CSV file. 6) Create and manipulate employee data stored in a CSV file, including listing, adding, deleting, and searching employees. 7) Create and manipulate student marks stored in a CSV file, including listing data, searching students, adding, fetching, and

Uploaded by

Lakshaya A
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
You are on page 1/ 9

Lab Discussion5:

Programs using text, csv files

Jeya Pandian. M
APII/CSE
Srinivasa Ramanujan Centre
SASTRA
1.Programs using text files

Write a program that accepts a comma separated


sequence of words as input and prints the words in a
comma-separated sequence after sorting them
alphabetically.
 Suppose the following input.txt file is supplied to
the program:
without, hello, bag, …, world
 Then, the content of output.txt file should be:

bag, … hello, without, world


* Add proper file and io exception handling functions.

CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 2


2.Programs using text files

Write a program that accepts a sentence and


calculate the number of letters and digits.
 Suppose the following input.txt is supplied:

hello world! 123


 Then, the content of output.txt should be:

LETTERS: 10
DIGITS: 3
SYMBOLS: 3 (includes whitespace)
* Add proper file and io exception handling functions.

CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 3


3.Programs using text files
An application requires the users to input username and
password to register. Write a program to check the validity of
password input by users.
 Create a user defined module function for the validity

checks.
 Following are the criteria for checking the password:

1. At least 1 small letter between [a-z]


2. At least 1 number between [0-9]
3. At least 1 capital letter between [A-Z]
4. At least 1 special character from [$#@]
5. Minimum length of transaction password: 6
6. Maximum length of transaction password: 12

CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 4


3.Programs using text files

 Your program should accept a sequence of passwords and


will check them according to the above criteria.
 Passwords that match the criteria are to be stored and

printed.
Example
 If the following passwords are given from console input to

the program:
ABd1234@1,a F1#,2w3E*,2We3345
 Then, the content of output.txt should be:

ABd1234@1

CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 5


4.Programs using text files

Write a program to compute the frequency of the words from


the input.txt. The output.txt file should store output after
sorting the key alphanumerically.
 Suppose the following input is supplied to the program:

New to Python or choosing between Python 2 and


Python 3? Read Python 2 or Python 3.
 Then, the output should be:

2:2
3.:1
3?:1
New:1
Python:5
....
CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 6
5.Create and Manipulate trip data
using csv file

CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 7


6.Create and Manipulate employees
data using csv file
 Consider ‘employee.csv’ stores the employee details such as
employ_id,name,email,phone_number,hire_date,salary,manager_id,dep
artment_id.
Create a python program to implement the following Hierarchy chart:
main()
-menu()
1.list_employees()
2.add_employee()
3.del_employee()
4.search_employee()

write_employee()
read_employee()

CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 8


7.Create and Manipulate student
marks data using csv file
 Consider ‘scores.csv’ stores the details such as stud_id, stud_name,
m1,m2,m3,m4,m5,total,avg

Create a python program to implement the following functions under main()


 list_data() – display all scores
 search_student()
 write_student() – add new student score record
 calc_tot_avg() - update total and average marks
 read_student() – fetch a student score record

* Add proper file and io exception handling functions.

CSE304-Python Programming with Web Frameworks Jeya Pandian.M/AP/CSE/SRC 9

You might also like