I like working in an IJulia notebook and would like to print the status of some process on the same line over and over again.
Taking the example given in the link below, we desire some output:
Downloading File FooFile.txt [47%]
and want to avoid something like this:
Downloading File FooFile.txt [47%]
Downloading File FooFile.txt [48%]
Downloading File FooFile.txt [49%]
In case of Python I found an answer here.
What would be a solution?
Writing Console Output in Java refers to writing the output of a Java program to the console or any particular file. The methods used for streaming output are defined in the PrintStream class. The methods used for writing console output are print (), println () and write (). Methods of Writing Console Output in Java-print () and println ()
The methods used for writing console output are print (), println () and write (). Both print () and println () methods are used to direct the output to the console.
If Write-Output is the last command in the pipeline, the objects are displayed in the console. Writes the specified objects to the pipeline. If Write-Output is the last command in the pipeline, the objects are displayed in the console.
One of the built-in aliases for Write-Output is echo and similar to other shells that use echo, the default behavior is to display the output at the end of a pipeline. In PowerShell, it is generally not necessary to use the cmdlet in instances where the output is displayed by default.
The "magic" in the Python answer isn't unique to Python… it's just the \r
character: it resets the cursor position to the beginning of the line (without creating a new line). Subsequent print instructions will just overwrite the previous text if your terminal supports such cursor movements.
In Julia:
print("Download progress: $(progress)% \r")
flush(stdout)
You can also take a look at ProgressMeter.jl for fancier cursor movements and output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With