0

I am trying to find a way to display a txt/csv file to the user of my Python script. Everytime I search how to do it, I keep finding information on how to open/read/write etc ... But I just want to display the file to the user.

Thank you in advance for your help.

Jeremy L.
  • 136
  • 11

2 Answers2

3

if you want the file to open with its associated default program, use startfile.

os.startfile("path/to/file") # may only work on Windows
Adam Smith
  • 52,157
  • 12
  • 73
  • 112
1

It really depends what you mean by "display" the file. When we display text, we need to take the file, get all of its text, and put it onto the screen. One possible display would be to read every line and print them. There are certainly others. You're going to have to open the file and read the lines in order to display it, though, unless you make a shell command to something like vim file.txt.

gregkow
  • 560
  • 2
  • 11