I Haz Codes

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Menu
Reading from a file
Writing to a file
Writing to a CSV file
Reading from a CSV file
File handling

File handling in python is all about manipulating strings. It requires you to think differently about your I/O operations. Instead of printing to the screen, you write to a file. Instead of using input, you read from a file.

Reading from a file

Learn Reading from a file requires you to understand how files work. In this lesson you will learn about file handles, open, close and readline. Try Write a program which will read in numbers from a file and add them up displaying a total. When you read each line in you must cast it to […]

Writing to a file

Learn In this lesson you will learn how to write single values to each line. It will make use of the write mode in python. Try Write a program which will act as a notepad. It should Open a new file in write mode. Ask the user to enter sentences. When the user enters the […]

Writing to a CSV file

Learn In this lesson you will learn how to write multiple values to each line. It will allow you to create a simple CSV file. Try Write a file which will allow you to add new names and phone numbers to a file. Each line of the file would look like the example on the […]

Reading from a CSV file

Learn In this lesson you will lean how to use split in order to read records from a CSV file. Try Read through a file with scores in it. Find the highest and lowest score from the file and display that on screen.

Comments are closed.

Information