SlideShare a Scribd company logo
1 of 35
HANDLING
COMPUTER FILES I
Wednesday, November 2, 2016
LEARNING OUTCOMES:
At the end of the lesson, I should be able to:
a. Identify computer file contents
b. Identifying and organizing files
c. Semantics of computer files
d. Basic operation on computer files
e. Steps involved in creating
FILE CONTENTS
All information in a file is always in binary form or a series of
ones and zeros. A document includes any file you have
created. It can be a true text document, sound file, graphics,
images, or any other type of information the computer can
create, store, or size from the internet.
PROGRAM FILES
They contain instructions for the computer’s microprocessor
and tell the computer what to do.
DATA FILES
These include all other files on disk that are not exactly
programs or documents. These include support files for
programs, temporary files, and other random stuff that must
be saved inside the computer.
SEMANTICS
Although the way programs manipulate files varies according
to the operating system and file system involved, the following
operations are typical:
(i) Creating a file with a given name.
(ii) Setting attributes that control operations on the file.
(iii) Opening a file to use its content.
(iv) Reading or updating the content.
(v) Committing updated contents to durable storage
Closing the file, thereby losing access until it is opened again.
IDENTIFYING AND
ORGANIZING FILES
In modern computer system, files are typically accessed using
names also known as file name. Most computers organize files
into hierarchies using folders, directories or catalogs. The
concept is the same irrespective of the terminology used. Each
folder can contain an arbitrary number of files, and it can also
contain other folders. These other folders are referred to as
sub folders. Sub folders can contain still more files and folders
and so on, thus building a tree–like structure in which one
“master folder” can contain any number of levels of other
folders and files.
BASIC FILE OPERATIONS
The basic file operations are:
i. Create (The act of making new file).
ii. Delete (To remove a file from a disk).
iii. Retrieve (To find a file and bring it back).
iv. Copy (To produce something so that it is the same as an original
piece of work)
v. View (See the file in a folder).
vi. Update (To make something more suitable for use now by
adding new information or changing design).
vii. Open (To open a file for editing).
viii. Close (To close the edited file).
CREATING A SEQUENTIAL FILE
These are the ways to organize data in a sequential file:
1. Choose a DOS file name. Some examples are INCOME.86, CUSTOMER.DAT and FORT500.
2. Choose a number from 1 through 255 to be the reference number of the file. While the file is in use,
it will be identified by this number.
3. Execute the statement
OPEN filename FOR OUTPUT AS #n
Where n is the reference number.
4. Place data into the file with the WRITE*statement. If a$ is a string, then the statement
WRITE #n, a$
writes string a$ surrounded by quotation marks into the file . If c is a number then the statement
WRITE #n, c
writes the number c, without any leading or trailing spaces, into file number n. The statement
WRITE #n, a$, c
writes a$ and c as before, but comma separating them. Similarly, if the statement WRITE*n is followed by
a list of several strings and / or numbers separated by commas, then all the string and numbers appear as
before, separated by commas. After each WRITE* statement is executed, the characters f and El are
placed into the file.
5. After all the data have been recorded in the file, execute
CLOSE #n
Where n is the reference number. This statement breaks the communication
line with the file and dissociates the number n from the file.
Example: Write a program to create the file. Use EOD as a sentinel to
indicate that all the data has been read.
Solution
REM Create the file YOB.DAT and record some data into it
OPEN “YOB.DAT” FOR OUTPUT AS #1
READ name$, year
DO WHILE name$, year <> “EOD”
WRITE #1, name$, year
READ name$, year LOOP
CLOSE #1
REM ----Data: name, year of birth
DATA Barbra, 1942
DATA Ringo, 1940
DATA Sylvester, 1946
DATA EOD, 0
END
ASSIGNMENT
Read up: “sequential access”.
TERMINOLOGIES
1. EOF – end of file
2. EOD – end of document
HANDLING
COMPUTER FILES II
Wednesday, November 2, 2016
LEARNING OUTCOMES
At the end of the lesson, I should be able to:
a. Access sequential file
b. State effects of file insecurity
c. Identify file security methods
d. Advantages of computerized files
e. State limitations of computerized files
ACCESS A SEQUENTIAL FILE
Data stored in a sequential file can read in order and assigned to
variables with the following steps:
1. Choose a number from 1 through 255 to be the reference number
of the file. This number is not necessary to be the same number that
was used when the file was recorded.
2. Execute the statement
OPEN filename FOR INPUT AS #n
Where n is the reference number. This procedure is referred to as
opening a file for input. It establishes a communication line between
the computer and the disk drive for reading data from the diskette.
3. Read data from the file with the INPUT* statement. INPUT*
statement assigns data from file to variable.
INPUT #n. var1, var2, ……
4. After the desired items have been found or all the data has been
read from the file, close the file with the statement CLOSE #n.
5. Basic function EOF; it tells us if we have reached the end of a file.
For example the condition EOF (n) will be true if the end of file n has
been reached and false otherwise.
EXAMPLE: Write a program to display a table showing the ages in 1991 of the people in the
sequential file YOB.DAT.
Solution
REM Process data from YOB.DAT file to find ages in 1991
CLS
OPEN “YOB.DAT” FOR INPUT AS #5
PRINT “NAME”, “Age in 1991”
DO WHILE NOT EOF (5)
REM Process the entire file
INPUT #5, name$, year
PRINT name$, 1991 – year
REM Display name and age in 1991
LOOP
CLOSE #5
END
[run]
Name Age in 1991
Barbra 49
Ringo 51
Sylvester 45
Johnny 65
PROTECTING FILES
Many modern computer systems provide methods for
protecting files against accidental and deliberate damage.
Computer with multi users implement file permissions to
control who may or may not modify, delete or create files and
folders. A user may be given permission to modify a file or
folder, but not to delete while some may be permitted to only
read the contents and not permitted to modify or delete the
content.
File security is a feature of your file system which controls which
users can access which files, and places limitations on what
users can do to files.
Effects of file insecurity
(a) Data loss: Computer users and many experts often loss data
permanently destroyed, with no hope of recovery.
FILE INSECURITY
CAUSES OF DATA LOSS
Customer Perception
Human error
40%
Computer viruses
15%
Natural Disasters
3%
Hardware or System Problem
28%
Software Corruption or Program Problem
12%
(b) Overwriting
This is a process of writing a binary set of data on a memory.
Data that has been overwritten is generally considered to be
unrecovered.
FILE SECURITY METHODS
(i) BACK UP: This is refers to making copies of data so that these
additional copies are used to restore the original after loss event. It is
also a method of making copies of the file in a separate location so
that they can be restored if something happen to the computer. This
can be done by using removable media such as rewritable CD,
memory card, flash etc.
(ii) VIRUS: This is a self – replicating program that copies itself and
that can infect other programs by modifying them or their
environment such that a call to an infected program implies a call to
a virus.
ANTIVIRUS: This is software to protect your computer from viruses
that may try to infect your computer or might have done so.
(iii) PASSWORD PROTECTION: It can prevent people accessing
computer system, account files or parts of files by requiring a user to
enter password.
(iv) STORAGE DEVICE LABELING: You should label your storage
devices like floppies, CDs, DVDs, Pen drivers etc. So that you know
what is exactly stored in them and so as not to accidentally delete of
format them.
ADVANTAGES OF COMPUTERIZED FILES
(i) Computer can form calculations quickly and
efficiently.
(ii) Data can be retrieved quickly and easily.
(iii) Documents that are lost can often be
retrieved.
(iv) Security is tight and hard to break into.
(v) Makes work easier.
(vi) Quicker to find things and sort things.
(vii) Transactions, accounts can be handled more
properly by computers than manually.
LIMITATIONS OF
COMPUTERISED FILES
i. Computerized filing system is expensive to set up.
ii. Not effective where there is irregular electric supply.
iii. Skilled labor with proficiency in computers is required.
iv. Data are separated and isolated
v. Data are often duplicated
vi. Application program dependent
vii. Incompatible data files
viii. They are vulnerable to virus and hacker attacks
ASSIGNMENT
Itemize the differences between computer files and manual
files.
TERMINOLOGIES
1. Sequential
2. Random
3. File access
4. Back up
5. Overwrite
END OF STUDENT’S NOTE
EXTRA TUTORIAL
Do not copy this following notes. They are for practice
purposes.
BASIC OPERATION ON
COMPUTER FILES
Operations on computer files include the following:
1. Create
2. Delete
3. Retrieve
4. Copy
5. View
6. Open
7. Update
8. Close
CREATING A SEQUENTIAL
FILE
The following statements and functions are used with
sequential files:
CLOSE LOF
EOF OPEN
INPUT# PRINT#
LINE INPUT# PRINT# USING
LOC UNLOCK
LOCK WRITE#
STEPS INVOLVED IN
CREATING SEQUENTIAL FILE
The following program steps are required to create a
sequential file and access the data in the file:
1.Open the file in output (O) mode. The current program will
use this file first for output:
OPEN "O",#1,"filename"
2.Write data to the file using the PRINT# or WRITE#
statement:
PRINT#1,A$ PRINT#1,B$ PRINT#1,C$
3.To access the data in the file, you must close the file and
reopen it in input (I) mode:
CLOSE #1 OPEN "I",#1,"filename
4.Use the INPUT# or LINE INPUT# statement to read data
from the sequential file into the program:
INPUT#1,X$,Y$,Z$
EXAMPLE 1
CLS
10 OPEN "O",#1,"DATA"
20 INPUT "NAME";N$
30 IF N$="DONE" THEN END
40 INPUT "DEPARTMENT";D$
50 INPUT "DATE HIRED";H$
60 PRINT#1,N$;","D$",";H$
70 PRINT:GOTO 20
RUN
NAME? MICKEY MOUSE
DEPARTMENT? AUDIO/VISUAL AIDS
DATE HIRED? 01/12/72
NAME? SHERLOCK HOLMES
DEPARTMENT? RESEARCH
DATE HIRED? 12/03/65
NAME? EBENEEZER SCROOGE
DEPARTMENT? ACCOUNTING
DATE HIRED? 04/27/78
NAME? SUPER MANN
DEPARTMENT? MAINTENANCE
DATE HIRED? 08/16/78
NAME? DONE
OK
ACCESSING A SEQUENTIAL
FILE
The program in Example 2 accesses the file data, created in the program
in Example 1, and displays the name of everyone hired in 1978.
Example 2:
CLS
10 OPEN "I",#1,"DATA"
20 INPUT#1,N$,D$,H$
30 IF RIGHT$(H$,2)="78" THEN PRINT N$
40 GOTO 20
50 CLOSE #1
RUN
EBENEEZER SCROOGE
SUPER MANN
Input past end in 20
Ok
BASIC FILE PROCESSING
To read and display files:
The table below would be used with a file name “EXAMFILE”.
Matric No. Math English Total Score
0001 50 90 140
0002 70 40 110
0003 80 60 150
EXAMPLE 3
10 CLS
20 OPEN “EXAMFILE.TXT” FOR INPUT AS #1
30 PRINT #1 “Matric No. Maths English Total Score”
40 PRINT #1 “0001 50 90 140”
50 PRINT #1 “0002 70 40 110”
60 PRINT #1 “0003 80 60 160”
70 CLOSE #1
80 OPEN “EXAMFILE.TXT” FOR OUTPUT AS #1
90 DO WHILE NOT EOF(1)
100 INPUT #1, text$
110 PRINT text$
120 LOOP
130 CLOSE #1
140 END
END OF TUTORIAL
Thank you

More Related Content

What's hot

Lesson 1 computer safety and maintenance
Lesson 1   computer safety and maintenanceLesson 1   computer safety and maintenance
Lesson 1 computer safety and maintenanceSchool
 
Record-client-support-pptx.pdf
Record-client-support-pptx.pdfRecord-client-support-pptx.pdf
Record-client-support-pptx.pdfteshomeneguse
 
Relational data base management system (Unit 1)
Relational data base management system (Unit 1)Relational data base management system (Unit 1)
Relational data base management system (Unit 1)Ismail Mukiibi
 
Computer repair and maintenance
Computer repair and maintenanceComputer repair and maintenance
Computer repair and maintenanceCornelius Micah
 
MS Word - Paragraph Indenting and Line Spacing
MS Word - Paragraph Indenting and Line SpacingMS Word - Paragraph Indenting and Line Spacing
MS Word - Paragraph Indenting and Line Spacingkross015
 
Database Security
Database SecurityDatabase Security
Database Securityalraee
 
Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Jotham Gadot
 
Ms access ppt 2017 by Gopal saha
Ms access ppt 2017 by Gopal sahaMs access ppt 2017 by Gopal saha
Ms access ppt 2017 by Gopal saha253253
 
DOS - Disk Operating System
DOS - Disk Operating SystemDOS - Disk Operating System
DOS - Disk Operating SystemMeqdad Darweesh
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its ComponentsMahmuda Rahman
 
File Management
File ManagementFile Management
File Managementspickul
 

What's hot (20)

File management
File managementFile management
File management
 
Codds rule
Codds ruleCodds rule
Codds rule
 
Ms DOS
Ms DOSMs DOS
Ms DOS
 
Lesson 1 computer safety and maintenance
Lesson 1   computer safety and maintenanceLesson 1   computer safety and maintenance
Lesson 1 computer safety and maintenance
 
Record-client-support-pptx.pdf
Record-client-support-pptx.pdfRecord-client-support-pptx.pdf
Record-client-support-pptx.pdf
 
Relational data base management system (Unit 1)
Relational data base management system (Unit 1)Relational data base management system (Unit 1)
Relational data base management system (Unit 1)
 
Computer repair and maintenance
Computer repair and maintenanceComputer repair and maintenance
Computer repair and maintenance
 
Desktop icons
Desktop iconsDesktop icons
Desktop icons
 
MS Word - Paragraph Indenting and Line Spacing
MS Word - Paragraph Indenting and Line SpacingMS Word - Paragraph Indenting and Line Spacing
MS Word - Paragraph Indenting and Line Spacing
 
ppt on cmd cammand
ppt on cmd cammandppt on cmd cammand
ppt on cmd cammand
 
Database Security
Database SecurityDatabase Security
Database Security
 
Data models
Data modelsData models
Data models
 
Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01
 
Ms access ppt 2017 by Gopal saha
Ms access ppt 2017 by Gopal sahaMs access ppt 2017 by Gopal saha
Ms access ppt 2017 by Gopal saha
 
Lesson-13-Desktop-Icons.pptx
Lesson-13-Desktop-Icons.pptxLesson-13-Desktop-Icons.pptx
Lesson-13-Desktop-Icons.pptx
 
DOS - Disk Operating System
DOS - Disk Operating SystemDOS - Disk Operating System
DOS - Disk Operating System
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its Components
 
Computer virus
 Computer virus Computer virus
Computer virus
 
File Management
File ManagementFile Management
File Management
 
Ms access 2010
Ms access 2010Ms access 2010
Ms access 2010
 

Similar to Handling computer files

File handling in qbasic
File handling in qbasicFile handling in qbasic
File handling in qbasicSmritiGurung4
 
File handling.pptx
File handling.pptxFile handling.pptx
File handling.pptxVishuSaini22
 
Introduction of file handling
Introduction of file handlingIntroduction of file handling
Introduction of file handlingVC Infotech
 
pointer, structure ,union and intro to file handling
 pointer, structure ,union and intro to file handling pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingRai University
 
Sequential file programming patterns and performance with .net
Sequential  file programming patterns and performance with .netSequential  file programming patterns and performance with .net
Sequential file programming patterns and performance with .netMichael Pavlovsky
 
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handlingRai University
 
Working with the IFS on System i
Working with the IFS on System iWorking with the IFS on System i
Working with the IFS on System iChuck Walker
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingChereLemma2
 
Hsc computer science chap 1 Operating System (1).pdf
Hsc computer science chap 1 Operating System  (1).pdfHsc computer science chap 1 Operating System  (1).pdf
Hsc computer science chap 1 Operating System (1).pdfAAFREEN SHAIKH
 
ExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdfExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdfaquacare2008
 

Similar to Handling computer files (20)

File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 
File handling in qbasic
File handling in qbasicFile handling in qbasic
File handling in qbasic
 
File handling.pptx
File handling.pptxFile handling.pptx
File handling.pptx
 
Introduction of file handling
Introduction of file handlingIntroduction of file handling
Introduction of file handling
 
INT 1010 04-5.pdf
INT 1010 04-5.pdfINT 1010 04-5.pdf
INT 1010 04-5.pdf
 
File operations
File operationsFile operations
File operations
 
C) ICT Application
C) ICT ApplicationC) ICT Application
C) ICT Application
 
pointer, structure ,union and intro to file handling
 pointer, structure ,union and intro to file handling pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
 
Sequential file programming patterns and performance with .net
Sequential  file programming patterns and performance with .netSequential  file programming patterns and performance with .net
Sequential file programming patterns and performance with .net
 
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
 
Edubooktraining
EdubooktrainingEdubooktraining
Edubooktraining
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
DFSNov1.pptx
DFSNov1.pptxDFSNov1.pptx
DFSNov1.pptx
 
Working with the IFS on System i
Working with the IFS on System iWorking with the IFS on System i
Working with the IFS on System i
 
C- language Lecture 8
C- language Lecture 8C- language Lecture 8
C- language Lecture 8
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ Programming
 
Hsc computer science chap 1 Operating System (1).pdf
Hsc computer science chap 1 Operating System  (1).pdfHsc computer science chap 1 Operating System  (1).pdf
Hsc computer science chap 1 Operating System (1).pdf
 
ExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdfExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdf
 

More from Samuel Igbanogu

More from Samuel Igbanogu (16)

Systems development cycle
Systems development cycleSystems development cycle
Systems development cycle
 
Data conversion
Data conversionData conversion
Data conversion
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
Classification of computers with respect to size
Classification of computers with respect to sizeClassification of computers with respect to size
Classification of computers with respect to size
 
Classification of computers by type
Classification of computers by typeClassification of computers by type
Classification of computers by type
 
Classification of computers by generation
Classification of computers by generationClassification of computers by generation
Classification of computers by generation
 
File organisation
File organisationFile organisation
File organisation
 
Computer system soft ware
Computer system soft wareComputer system soft ware
Computer system soft ware
 
Relational models
Relational modelsRelational models
Relational models
 
Entity relationship model
Entity relationship modelEntity relationship model
Entity relationship model
 
Output devices
Output devicesOutput devices
Output devices
 
Concept of computer files
Concept of computer filesConcept of computer files
Concept of computer files
 
Computing devices i
Computing devices iComputing devices i
Computing devices i
 
Logic gates i & ii
Logic gates i & iiLogic gates i & ii
Logic gates i & ii
 
Input devices
Input devicesInput devices
Input devices
 
Normal forms
Normal formsNormal forms
Normal forms
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

Handling computer files

  • 2. LEARNING OUTCOMES: At the end of the lesson, I should be able to: a. Identify computer file contents b. Identifying and organizing files c. Semantics of computer files d. Basic operation on computer files e. Steps involved in creating
  • 3. FILE CONTENTS All information in a file is always in binary form or a series of ones and zeros. A document includes any file you have created. It can be a true text document, sound file, graphics, images, or any other type of information the computer can create, store, or size from the internet.
  • 4. PROGRAM FILES They contain instructions for the computer’s microprocessor and tell the computer what to do.
  • 5. DATA FILES These include all other files on disk that are not exactly programs or documents. These include support files for programs, temporary files, and other random stuff that must be saved inside the computer.
  • 6. SEMANTICS Although the way programs manipulate files varies according to the operating system and file system involved, the following operations are typical: (i) Creating a file with a given name. (ii) Setting attributes that control operations on the file. (iii) Opening a file to use its content. (iv) Reading or updating the content. (v) Committing updated contents to durable storage Closing the file, thereby losing access until it is opened again.
  • 7. IDENTIFYING AND ORGANIZING FILES In modern computer system, files are typically accessed using names also known as file name. Most computers organize files into hierarchies using folders, directories or catalogs. The concept is the same irrespective of the terminology used. Each folder can contain an arbitrary number of files, and it can also contain other folders. These other folders are referred to as sub folders. Sub folders can contain still more files and folders and so on, thus building a tree–like structure in which one “master folder” can contain any number of levels of other folders and files.
  • 8. BASIC FILE OPERATIONS The basic file operations are: i. Create (The act of making new file). ii. Delete (To remove a file from a disk). iii. Retrieve (To find a file and bring it back). iv. Copy (To produce something so that it is the same as an original piece of work) v. View (See the file in a folder). vi. Update (To make something more suitable for use now by adding new information or changing design). vii. Open (To open a file for editing). viii. Close (To close the edited file).
  • 9. CREATING A SEQUENTIAL FILE These are the ways to organize data in a sequential file: 1. Choose a DOS file name. Some examples are INCOME.86, CUSTOMER.DAT and FORT500. 2. Choose a number from 1 through 255 to be the reference number of the file. While the file is in use, it will be identified by this number. 3. Execute the statement OPEN filename FOR OUTPUT AS #n Where n is the reference number. 4. Place data into the file with the WRITE*statement. If a$ is a string, then the statement WRITE #n, a$ writes string a$ surrounded by quotation marks into the file . If c is a number then the statement WRITE #n, c writes the number c, without any leading or trailing spaces, into file number n. The statement WRITE #n, a$, c writes a$ and c as before, but comma separating them. Similarly, if the statement WRITE*n is followed by a list of several strings and / or numbers separated by commas, then all the string and numbers appear as before, separated by commas. After each WRITE* statement is executed, the characters f and El are placed into the file. 5. After all the data have been recorded in the file, execute CLOSE #n
  • 10. Where n is the reference number. This statement breaks the communication line with the file and dissociates the number n from the file. Example: Write a program to create the file. Use EOD as a sentinel to indicate that all the data has been read. Solution REM Create the file YOB.DAT and record some data into it OPEN “YOB.DAT” FOR OUTPUT AS #1 READ name$, year DO WHILE name$, year <> “EOD” WRITE #1, name$, year READ name$, year LOOP CLOSE #1 REM ----Data: name, year of birth DATA Barbra, 1942 DATA Ringo, 1940 DATA Sylvester, 1946 DATA EOD, 0 END
  • 12. TERMINOLOGIES 1. EOF – end of file 2. EOD – end of document
  • 14. LEARNING OUTCOMES At the end of the lesson, I should be able to: a. Access sequential file b. State effects of file insecurity c. Identify file security methods d. Advantages of computerized files e. State limitations of computerized files
  • 15. ACCESS A SEQUENTIAL FILE Data stored in a sequential file can read in order and assigned to variables with the following steps: 1. Choose a number from 1 through 255 to be the reference number of the file. This number is not necessary to be the same number that was used when the file was recorded. 2. Execute the statement OPEN filename FOR INPUT AS #n Where n is the reference number. This procedure is referred to as opening a file for input. It establishes a communication line between the computer and the disk drive for reading data from the diskette. 3. Read data from the file with the INPUT* statement. INPUT* statement assigns data from file to variable. INPUT #n. var1, var2, …… 4. After the desired items have been found or all the data has been read from the file, close the file with the statement CLOSE #n. 5. Basic function EOF; it tells us if we have reached the end of a file. For example the condition EOF (n) will be true if the end of file n has been reached and false otherwise.
  • 16. EXAMPLE: Write a program to display a table showing the ages in 1991 of the people in the sequential file YOB.DAT. Solution REM Process data from YOB.DAT file to find ages in 1991 CLS OPEN “YOB.DAT” FOR INPUT AS #5 PRINT “NAME”, “Age in 1991” DO WHILE NOT EOF (5) REM Process the entire file INPUT #5, name$, year PRINT name$, 1991 – year REM Display name and age in 1991 LOOP CLOSE #5 END [run] Name Age in 1991 Barbra 49 Ringo 51 Sylvester 45 Johnny 65
  • 17. PROTECTING FILES Many modern computer systems provide methods for protecting files against accidental and deliberate damage. Computer with multi users implement file permissions to control who may or may not modify, delete or create files and folders. A user may be given permission to modify a file or folder, but not to delete while some may be permitted to only read the contents and not permitted to modify or delete the content.
  • 18. File security is a feature of your file system which controls which users can access which files, and places limitations on what users can do to files. Effects of file insecurity (a) Data loss: Computer users and many experts often loss data permanently destroyed, with no hope of recovery. FILE INSECURITY
  • 19. CAUSES OF DATA LOSS Customer Perception Human error 40% Computer viruses 15% Natural Disasters 3% Hardware or System Problem 28% Software Corruption or Program Problem 12%
  • 20. (b) Overwriting This is a process of writing a binary set of data on a memory. Data that has been overwritten is generally considered to be unrecovered.
  • 21. FILE SECURITY METHODS (i) BACK UP: This is refers to making copies of data so that these additional copies are used to restore the original after loss event. It is also a method of making copies of the file in a separate location so that they can be restored if something happen to the computer. This can be done by using removable media such as rewritable CD, memory card, flash etc. (ii) VIRUS: This is a self – replicating program that copies itself and that can infect other programs by modifying them or their environment such that a call to an infected program implies a call to a virus. ANTIVIRUS: This is software to protect your computer from viruses that may try to infect your computer or might have done so. (iii) PASSWORD PROTECTION: It can prevent people accessing computer system, account files or parts of files by requiring a user to enter password. (iv) STORAGE DEVICE LABELING: You should label your storage devices like floppies, CDs, DVDs, Pen drivers etc. So that you know what is exactly stored in them and so as not to accidentally delete of format them.
  • 22. ADVANTAGES OF COMPUTERIZED FILES (i) Computer can form calculations quickly and efficiently. (ii) Data can be retrieved quickly and easily. (iii) Documents that are lost can often be retrieved. (iv) Security is tight and hard to break into. (v) Makes work easier. (vi) Quicker to find things and sort things. (vii) Transactions, accounts can be handled more properly by computers than manually.
  • 23. LIMITATIONS OF COMPUTERISED FILES i. Computerized filing system is expensive to set up. ii. Not effective where there is irregular electric supply. iii. Skilled labor with proficiency in computers is required. iv. Data are separated and isolated v. Data are often duplicated vi. Application program dependent vii. Incompatible data files viii. They are vulnerable to virus and hacker attacks
  • 24. ASSIGNMENT Itemize the differences between computer files and manual files.
  • 25. TERMINOLOGIES 1. Sequential 2. Random 3. File access 4. Back up 5. Overwrite
  • 27. EXTRA TUTORIAL Do not copy this following notes. They are for practice purposes.
  • 28. BASIC OPERATION ON COMPUTER FILES Operations on computer files include the following: 1. Create 2. Delete 3. Retrieve 4. Copy 5. View 6. Open 7. Update 8. Close
  • 29. CREATING A SEQUENTIAL FILE The following statements and functions are used with sequential files: CLOSE LOF EOF OPEN INPUT# PRINT# LINE INPUT# PRINT# USING LOC UNLOCK LOCK WRITE#
  • 30. STEPS INVOLVED IN CREATING SEQUENTIAL FILE The following program steps are required to create a sequential file and access the data in the file: 1.Open the file in output (O) mode. The current program will use this file first for output: OPEN "O",#1,"filename" 2.Write data to the file using the PRINT# or WRITE# statement: PRINT#1,A$ PRINT#1,B$ PRINT#1,C$ 3.To access the data in the file, you must close the file and reopen it in input (I) mode: CLOSE #1 OPEN "I",#1,"filename 4.Use the INPUT# or LINE INPUT# statement to read data from the sequential file into the program: INPUT#1,X$,Y$,Z$
  • 31. EXAMPLE 1 CLS 10 OPEN "O",#1,"DATA" 20 INPUT "NAME";N$ 30 IF N$="DONE" THEN END 40 INPUT "DEPARTMENT";D$ 50 INPUT "DATE HIRED";H$ 60 PRINT#1,N$;","D$",";H$ 70 PRINT:GOTO 20 RUN NAME? MICKEY MOUSE DEPARTMENT? AUDIO/VISUAL AIDS DATE HIRED? 01/12/72 NAME? SHERLOCK HOLMES DEPARTMENT? RESEARCH DATE HIRED? 12/03/65 NAME? EBENEEZER SCROOGE DEPARTMENT? ACCOUNTING DATE HIRED? 04/27/78 NAME? SUPER MANN DEPARTMENT? MAINTENANCE DATE HIRED? 08/16/78 NAME? DONE OK
  • 32. ACCESSING A SEQUENTIAL FILE The program in Example 2 accesses the file data, created in the program in Example 1, and displays the name of everyone hired in 1978. Example 2: CLS 10 OPEN "I",#1,"DATA" 20 INPUT#1,N$,D$,H$ 30 IF RIGHT$(H$,2)="78" THEN PRINT N$ 40 GOTO 20 50 CLOSE #1 RUN EBENEEZER SCROOGE SUPER MANN Input past end in 20 Ok
  • 33. BASIC FILE PROCESSING To read and display files: The table below would be used with a file name “EXAMFILE”. Matric No. Math English Total Score 0001 50 90 140 0002 70 40 110 0003 80 60 150
  • 34. EXAMPLE 3 10 CLS 20 OPEN “EXAMFILE.TXT” FOR INPUT AS #1 30 PRINT #1 “Matric No. Maths English Total Score” 40 PRINT #1 “0001 50 90 140” 50 PRINT #1 “0002 70 40 110” 60 PRINT #1 “0003 80 60 160” 70 CLOSE #1 80 OPEN “EXAMFILE.TXT” FOR OUTPUT AS #1 90 DO WHILE NOT EOF(1) 100 INPUT #1, text$ 110 PRINT text$ 120 LOOP 130 CLOSE #1 140 END