AME 209: 18. Data Input/Output (I/O)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/11

flashcard set

Earn XP

Description and Tags

By the end of this section, students should be able to... • Remember the role of data I/O in programming • Know the basic I/O operations required to write/read data • Differentiate between ASCII and binary file formats (review) • Perform basic I/O operations in Python: • Read/write ASCII and binary data • Handle ‘csv’ files using csv and pandas • Choose file formats based on readability, performance, and use case

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

12 Terms

1
New cards

Data I/O

The process of reading from or writing to files, enabling interaction between programs and external data.

2
New cards

ASCII File

Human-readable format (e.g., .txt, .csv); easier to debug but slower and larger in size.

3
New cards

Binary File

Machine-readable format (e.g., .npy, .npz); faster and smaller but not human-readable.

4
New cards

Use of ASCII vs. Binary

Choose ASCII for debugging and transparency, binary for speed and compact storage.

5
New cards

Basic File Access

Files must be opened before use and closed after to save data and free system resources.

6
New cards

open(fname, access_type)

Opens a file with name fname and operation type ('r', 'w', etc.). Returns a file object (fid).

7
New cards

File ID (fid)

A unique identifier Python uses to reference an open file.

8
New cards

File Access Modes

'r': read, 'w': write, 'a': append, 'r+': read/write, 'rb': read binary, etc.

9
New cards

Closing a File

Use fid.close() to ensure data integrity and prevent memory/resource leaks.

10
New cards

CSV Handling

Use csv (standard module) or pandas (powerful data analysis library) to read/write structured tabular data.

11
New cards

Choosing File Format

Depends on readability (ASCII), performance (binary), or data structure (CSV, JSON, etc.).

12
New cards

MATLAB vs. Python I/O

Both platforms support ASCII/binary operations but with different syntax and ecosystem preferences.