You completed Basic Data Structures: Arrays in .
Including all advanced topics & quizzes. 🎓
This lesson is also available in . Choose a language at the top of the page.
Your progress is not saved. Create an account or log in to save your progress.
Visualization supports Java, Python, C++, C, and JavaScript.
Data files
A data file is a small plain text file you attach to a Try It block, for example a CSV that the code reads and processes. When anyone clicks Run, the file is placed next to the program, so the code can open it by its name. Each file can be up to 100 KB, a block can have up to 3 files and 250 KB in total.
How it works
Open the Data files section of the block and choose Add file. The name shown is the exact name the code must use, capital letters included. Save spreadsheets as CSV UTF-8 before you add them.
Why this matters
Learners can practise reading and processing a real file without typing the data into the code.
Who can change this
Anyone who can edit the lesson. An administrator can switch the feature off for everyone; files that are already attached keep working.
Attach a plain text file your code can read (.txt, .md, .csv, .tsv or .json), for example open("data.csv"). Learners see it listed under the code.
-
Your code reads it as
Showing the first 2 KB.
In Java, the class with main() must be the first class in the code (it runs as Main), so the data files are ready before it starts.
Let learners load their own file
When this is on, learners see a "Use my own file" button under the code. The file they choose is plain text of up to 50 KB. It is available to the code under the name you set (input.txt unless you change it) and replaces an attached file with the same name for that run. It is sent only to run their code and is not shown to other learners.
How it works
Your code reads it by that name, exactly like an attached file. Choosing another file, clearing it, or switching the language version removes it again.
Why this matters
Learners can test the same code on their own data.
Who can change this
Anyone who can edit the lesson.
The learner's file is available to the code under this name. If you attached a file with the same name, the learner's file replaces it for that run.
Files your code can read
. If your program reads typed input instead (input(), Scanner(System.in), cin), choose Use as input.
Use as input
Some programs read what is typed in, using input(), Scanner(System.in) or cin, instead of opening a file. Use as input copies the text of a file into the Input box so you can run such a program on it. You can edit the text before you run, and undo if it replaced something you had typed.
How it works
The file is not moved: code that opens it by name still finds it.
-
Showing the first 2 KB.
Let learners load their own file
When this is on, learners see a "Use my own file" button under the code. The file they choose is plain text of up to 50 KB. It is available to the code under the name you set (input.txt unless you change it) and replaces an attached file with the same name for that run. It is sent only to run their code and is not shown to other learners.
How it works
Your code reads it by that name, exactly like an attached file. Choosing another file, clearing it, or switching the language version removes it again.
Why this matters
Learners can test the same code on their own data.
Who can change this
Anyone who can edit the lesson.
Ungraded practice: does not count toward your section grade.
No questions for this variant.
unanswered (). Unanswered questions are marked incorrect. Submit anyway?
Practice only: you have used all , so this run does not count.
Attempt of used.
Ungraded practice: does not count toward your section grade.
Sample files
.
-
Showing the first 2 KB.
Ungraded run. This does not use an attempt.
Practice only: you have used all , so this run does not count.
Attempt of used.
This topic has no content for the selected options/level.