File Handling Flashcards
o Temporary storage
o Example: storing a value in a variable
o The value you store is lost when the program
ends or the computer loses power.
o Volatile storage
Understanding Computer Files
Random access memory (RAM)
Understanding Computer Files
o Permanent Storage
o Non - Volatile Storage
o Example: saving a program to disk
o The value you store is not lost when a
computer loses power
Understanding Computer Files
Permanent storage
Understanding Computer Files
What are the two Broad Categories of Files?
Understanding Computer Files
Text file and Binary file
Understanding Computer Files
What is the type of file that fits the following descriptions?
* contain data that can be read in a text editor
* the data has been encoded using a scheme such as
ASCII Code or Unicode.
* includes facts and figures such as employee numbers,
names and salaries
Understanding Computer Files
Text file
Understanding Computer Files
What is the type of file that fits the following descriptions?
* Contains data that has not been encoded as text
* Examples images and music.
Understanding Computer Files
Binary file
Understanding Computer Files
____ have many common characteristics:
* Each has a Name
includes a dot (.) and a file extension that describes
the type of the file.
* Each has specific time of creation and last modified.
* Each has Size measured in bytes.
A byte is a small unit of storage.
Understanding Computer Files
Files
Understanding Computer Files
Computer Files on storage devices are the electronic equivalent of paper files stored in a file cabinets.
* For a (________) placing a paper documents in a folders and most computer users organize their files into
folders or directories.
Organizing Files
Better organization
Organizing Files
What tools are the folowing?
- Organization units on storage devices
- Each can contain multiple files
Organizing Files
Directories and Folders
Organizing Files
What type of hierarchy is this?
Describes the relationships between data components
Consists of:
* Characters
* Fields
* Records
* Files
Understanding the Data Hierarchy
Data Hierarchy
Understanding the Data Hierarchy
What is the term used to describe the following?
o Letters, numbers and special symbols
o Can type from a keyboard in one stroke (including
a space and tab)
o Made up of smaller elements called bits
Understanding the Data Hierarchy
Characters
Understanding the Data Hierarchy
What is the term used to describe the following?
o Single useful data items
o Composed of one or more characters
o Include items such as lastName, middleInitials,
streetAddress or annualSalary
Understanding the Data Hierarchy
Fields
Understanding the Data Hierarchy
What is the term used to describe the following?
- Group of fields that go together for some logical reason.
- A random name, address and salary aren’t very useful
- But if they’re your name, your address, your salary then that’s* your record.*
Understanding the Data Hierarchy
Records
Understanding the Data Hierarchy
What is the term used to describe the following?
- Group of related records
Understanding the Data Hierarchy
Files
Understanding the Data Hierarchy
What is the term used to describe the following?
- The broadest types are files that can be used for input and files that can be used for output.
- You declare files in the same way you declare variables and constants – by giving each file a data type and an identifier.
Example:
~~~
Declarations
InputFile employeeData
OutputFile updatedData
~~~
Performing File Operations
Declaring a file
Performing File Operations
What is the term used to describe the following?
- The broadest types are files that can be used for input and files that can be used for output.
- You declare files in the same way you declare variables and constants – by giving each file a data type and an identifier.
Example:
~~~
Declarations
InputFile employeeData
OutputFile updatedData
~~~
Performing File Operations
Declaring a file
Performing File Operations
What is the term used to describe the following?
o Before an application can use a data file, it must open
the file.
o Opening a file locates it on a storage device and
associates a variable name within your program with file.open employeeData "EmployeeData.dat"
Performing File Operations
Opening a file
Performing File Operations
What is the term used to describe the following?
Before you can use stored data within a program, you must load the data into computer memory.
o You use a copy that is transferred into a memory.
o When you copy data from a file on storage device into RAM, you read from the files.
o If data items have been stored in a file and a program needs them, you can write separate programming statements to input each field.
~~~
input name from employeeData
input address from employeeData
input payRate from employeeData
~~~
Performing File Operations
Reading from a file
Performing File Operations
What is the term used to describe the following?
When you store data in a computer file on a persistent
storage device.
* Copy data from RAM to the file.
* When you write data to a file, you usually do not include
explanations that make data easier for human to interpret, you just write facts and figures.
* No column headings “The pay rate is”, or no commas, dollar signs, percent.
~~~
output name, address, payRate to
updatedData
~~~
Performing File Operations
Writing to a file
Performing File Operations