Topic 8: Programming
File Handling is the use of programming techniques to work with information stored in text
files
Opening text files
file = open("[Link]","r")
Closing text files
[Link]()
Read line
[Link]()
OPENFILE "[Link]" FOR READ
endOfFile <- FALSE // Set end of file flag to false
WHILE NOT endOfFile DO
READFILE "[Link]", name // Read line 1(name)
name <- TRIM(name) // Remove extra spaces / new lines
READFILE "[Link]", department // Read line 2(department)
department <- TRIM (salary) // Remove extra spaces / new lines
READFILE "[Link]", salary // Read line 3 (salary)
salary <- TRIM(salary) // Remove extra spaces / new lines
READFILE "[Link]", age // Read line 4 (age)
age <- TRIM(age) // Remove extra spaces / new lines
Write line
[Link]("Oranges")
Append file
Topic 8: Programming 1
file = open("[Link]","a")
Topic 8: Programming 2