Display a file to the user with Python [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
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.

if you want the file to open with its associated default program, use startfile.
os.startfile("path/to/file") # may only work on Windows

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.

Related

How can I read an SVG file and draw something in it? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to read an SVG file in python 3.7. I would also like to draw several lines in this file, which contains a drawing. Drawing the lines in a newly created SVG file is no problem. One problem is opening an existing SVG file in Python, drawing in something new and then saving it again. Can someone help and tell me how I can open such a file and draw something in it? I was already looking for solutions on the internet but there was nothing that worked
i use a python lib named PYX
From the PyX Manual:
With the help of the svgfile.svgfile class, you can easily embed another SVG
file in your canvas, thereby scaling, aligning the content at discretion. The
most simple example looks like
from pyx import *
c = canvas.canvas()
c.insert(svgfile.svgfile(0, 0, "file.svg"))
c.writeSVGfile("output")

list clears when i end my app and re run it [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How can I define a list that is empty at first and append to it but not have it clear when I restart my app? I am using python language
The list has the proper values in it when the app is first ran, it is only when I restart my app that the list clears because of the empty list variable over rides the list that was just created. Thanks in advance
A list doesn’t get saved when closing a python program. If you want this you should save the list in a specific file and load this file everytime your python program opens. One of the basics of python is that lists, dictionairies etc don’t get saved on change or exit.

How would I get Python to create a file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
What I'm trying to do is get Python to create a batch file for me which I can put what the text is that I need in the file just by coding it. What I began to do is create a text file with the open() method, I then added the text I need in the batch file using write() but now I want it to be a .bat file with the text in that text file, any ideas?
When you create a new file with the open() function, you state its file name. Just give it a name with the .bat extension, and it has become a .bat file. Of course, this assumes the program is running in the Windows environment, where the concept of a .bat file makes sense.
Then just write the appropriate text into the file, then close the file properly with the close() function, or even better using the end of the with construct. You may need to flush the file system to ensure that all text was written to the file.
If you need more details, add more details to your question about your specific difficulty.

Notepad++ Formatting Issue [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have an issue, I am working on a jython project while editing it with Notepad++. I'm having an issue where I save the file, open it in normal notepad.exe and the file comes out completely different to how i edited it on Notepad++. It seems to be that wherever I pressed Enter for a new line, notepad++ formatted it to have a few spaces and the whole 150+ line code is word wrapped around five lines of carriage returns.
Any idea how I can fix this? I figure it's in settings but I don't know how to google for it and don't want to try every option until it works as notepad++ is quite feature rich!
Found out myself! Edit > EOL conversion > Windows Format Thanks ME! No, wait, credit goes to: this guy.

Need Help Opening, Parsing, and Closing a File in Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am Python newbie and I am trying to learn how to parse files but I really don't even know where to begin. I need to basically find a specific code inside the code to confirm the functionality of the run log supplied to me. I just need help in the steps to: Open a file, parse a file, and close a file on Python. If you need anymore info please let me know. I can't supply the code but I can try to give as much info as I can. Thanks!
Opening a file:
myLog = open("path/to/my/log", 'r')
Loop through the lines:
for line in myLog:
if foundMyThing(line):
print "Found it!"
Close it:
myLog.close()
Read the docs:
https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
with open("myfile.myextension",r) as f:
for line in f:
<parse each line>

Categories

Resources