0% found this document useful (0 votes)
3 views6 pages

Filepython

The document provides a list of sample Python programs focused on file handling, including reading, writing, and manipulating text and CSV files. Each program is described briefly, with a prompt to view a sample solution. The tasks range from reading entire files to generating multiple text files and handling CSV data.

Uploaded by

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

Filepython

The document provides a list of sample Python programs focused on file handling, including reading, writing, and manipulating text and CSV files. Each program is described briefly, with a prompt to view a sample solution. The tasks range from reading entire files to generating multiple text files and handling CSV data.

Uploaded by

hari190804
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

EXE – 5 ( Sample File Programs)

1. Read Entire File


Write a Python program to read an entire text file.

Click me to see the sample solution

2. Read First N Lines


Write a Python program to read first n lines of a file.

Click me to see the sample solution

3. Append Text and Display


Write a Python program to append text to a file and display the text.

Click me to see the sample solution

4. Read Last N Lines


Write a Python program to read last n lines of a file.

Click me to see the sample solution

5. File to List
Write a Python program to read a file line by line and store it into a list.

Click me to see the sample solution

6. File to Variable
Write a Python program to read a file line by line store it into a variable.
EXE – 5 ( Sample File Programs)

Click me to see the sample solution

7. File to Array
Write a Python program to read a file line by line store it into an array.

Click me to see the sample solution

8. Longest Words Finder


Write a python program to find the longest words.

Click me to see the sample solution

9. Line Count
Write a Python program to count the number of lines in a text file.

Click me to see the sample solution

10. Word Frequency Counter


Write a Python program to count the frequency of words in a file.

Click me to see the sample solution

11. Get File Size


Write a Python program to get the file size of a plain file.

Click me to see the sample solution

12. Write List to File


EXE – 5 ( Sample File Programs)

Write a Python program to write a list to a file.

Click me to see the sample solution

13. Copy File Contents


Write a Python program to copy the contents of a file to another file .

Click me to see the sample solution

14. Combine Lines from Two Files


Write a Python program to combine each line from first file with the
corresponding line in second file.

Click me to see the sample solution

15. Random Line Reader


Write a Python program to read a random line from a file.

Click me to see the sample solution

16. File Closed Check


Write a Python program to assess if a file is closed or not.

Click me to see the sample solution

17. Remove Newline Characters


Write a Python program to remove newline characters from a file.

Click me to see the sample solution


EXE – 5 ( Sample File Programs)

18. Count Words in File


Write a Python program that takes a text file as input and returns the number
of words of a given text file.

19. Extract Characters to List


Write a Python program to extract characters from various text files and puts
them into a list.

Click me to see the sample solution

20. Generate 26 Text Files


Write a Python program to generate 26 text files named A.txt, B.txt, and so on
up to Z.txt.

Click me to see the sample solution

21. Alphabet Lines File


Write a Python program to create a file where all letters of English alphabet
are listed by specified number of letters on each line.

Click me to see the sample solution

22. Read CSV Rows


Write a Python program to read each row from a given csv file and print a list
of strings.

Click me to see the sample solution

23. Tab Delimited CSV


Write a Python program to read a given CSV file having tab delimiter.
EXE – 5 ( Sample File Programs)

Click me to see the sample solution

24. CSV to List


Write a Python program to read a given CSV file as a list.

Click me to see the sample solution

25. CSV to Dictionary


Write a Python program to read a given CSV file as a dictionary.

Click me to see the sample solution

26. CSV Remove Initial Spaces


Write a Python program to read a given CSV files with initial spaces after a
delimiter and remove those initial spaces.

Click me to see the sample solution

27. CSV Clean Entries


Write a Python program that reads a CSV file and remove initial spaces,
quotes around each entry and the delimiter.

Click me to see the sample solution

7. Read Specific CSV Columns


Write a Python program to read specific columns of a given CSV file and print
the content of the columns.

Click me to see the sample solution


EXE – 5 ( Sample File Programs)

8. CSV Skip Header and Count


Write a Python program that reads each row of a given csv file and skip the
header of the file. Also print the number of rows and the field names.

Click me to see the sample solution

9. CSV Write Object Iterate


Write a Python program to create an object for writing and iterate over the
rows to print the values.

Click me to see the sample solution

10. List to CSV and Read


Write a Python program to write a Python list of lists to a csv file. After writing
the CSV file read the CSV file and display the content.

Click me to see the sample solution

11. Dict to CSV and Read


Write a Python program to write a Python dictionary to a csv file. After writing
the CSV file read the CSV file and display the content.

Click me to see the sample solution

You might also like