0% found this document useful (0 votes)
4 views2 pages

File Handling Techniques in Programming

The document discusses file handling in programming, focusing on opening, closing, reading, writing, and appending text files. It provides examples of code for reading lines from a file and trimming extra spaces. Additionally, it includes a method for appending data to a file.
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)
4 views2 pages

File Handling Techniques in Programming

The document discusses file handling in programming, focusing on opening, closing, reading, writing, and appending text files. It provides examples of code for reading lines from a file and trimming extra spaces. Additionally, it includes a method for appending data to a file.
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

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

You might also like