Reading from and writing to files
The files you will be working with are comma separated variable text files.
Success with files requires you to have a good understanding of processing lists. Section 10 of the CSNEWBS website goes over the basics with examples and tasks. This website also There are lots of practice tasks below the video. |
Watch the video and create the programs as shown.
Make sure you have your PLS and make some notes on it.
Practice Tasks
File handling basics from 101 Computing.......read the intro and then take the Class Register challenge. Remember, for GCSE you only need to know the read, write and append modes. CLICK HERE!
Class register - reading and writingA short reading and writing task. Click here or on the picture.
|
Zoo animals - reading and strippingDownload the program and the text file below. Remember to save the program and the text file in the same folder.
Put the program into Thonny and follow the instructions. Use the Debugger (F7) to understand it. Complete the challenges at the end.
|
Star Wars - reading taskFollow the instructions to create the program. Just use the simple method mentioned first on this webpage.
|
Playlist - reading and formatting task - code given & explained
Two files are linked below - the task and the text file. Download them both. Follow the instructions on the task sheet. Remember to save your Python file into the same folder as the text file.
|
Italian Restaurant Task (from 101 Computing)A more reading complex task which requires more processing of the data.
Click HERE or on the picture to access it. |
Radish survey task
Another more complex task which requires the data in the text file to be processed and counted. Instructions including an example output are included in the task sheet linked below. Remember to save your Python file in the same folder as the text file.
|
IP addresses and DNS lookup - using 2 files
Three files are linked below: the task, a text file of IP addresses and a text file of domain names (web addresses). The aim of the task is to read both text files into separate lists and then to allow a user to enter a web address and for the program to return the IP address.
|