So you developed a Python program that reads data using input()
or stdio.readString()
and want to input a massive amount of data from a file called input.txt
. How do you take the data from your file and place it on the standard input stream for your program?
Mac and Ubuntu: Terminal
python3 program.py < input.txt
If you have command line arguments c1
, c2
and c3
:
python3 program.py c1 c2 c3 < input.txt
Windows
Command Prompt
python program.py < input.txt
If you have command line arguments c1
, c2
and c3
:
python program.py c1 c2 c3 < input.txt
Powershell
Get-Content input.txt | python program.py
If you have command line arguments c1
, c2
and c3
:
Get-Content input.txt | python program.py c1 c2 c3