I have a txt file consisting some numbers with space and I want to make it as three 4*4 matrixes in python. Each matrix is also divided with two symbols in the text file. The format of the txt file is like this: My code is now like this but it is not showing the output I want. Can you
Tag: file
How can we Read just float values from the lines of a file?
I want to read a file line by line and use some elements written in that file as the learning rate, epochs, and batch size in my neural network to configure it. My code is like this: and the result is like this: Do you have any idea how I can assign the values written in each line to my
Collect data from multiple files in a folder and save it as a variable
I want to collect the data from the first line in each .txt file, all the files are in the same folder. I then want to save it in the variable: (addPlayer) This will be needed to add items to a pqt5 list Folder directory: C:UsersHendreOneDriveDocumentsCourseWorkProjectPlayers Code: Answer I think that will help you
Change Value of a Kivy Property from a seperate File
So at the moment im having a problem with Kivy, which i cant resolve. I have a situation where i want to change the Value of a Kivy NumericProperty in a File “A” from another programm “B”, thus that the program “C”, where all the Kivy interface stuff is, detects the change and updates the value on the screen. File
How do I check the existing file with same name in the directory and use python to rename new files to save?
I am using plt.savefig to save a plot generated by matplotlib.pyplot, and I want to save my figure with different names each time I run the code. How can I do that? Answer The easiest would probably be to use the current time, if you don’t save multiple files per second.
python program to write a code that receives file route and return a tuple with things from the file
I need to write a program to receive a file. her content is something like that: this is my code: the program needs to return a tuple that contain the (name of the longest song, number of lines in the file, most appearing artist in the file) But it doesn’t work and return: Answer
How to substitute a variable for a string when using the open() function in python
I am beginner to python and coding in general, and am attempting to pass a variable as an argument to the open() function. regularly I would write something like this: however I would like to do something along these lines: Any explanations or resources would be very helpful, thanks in advance Answer is wrong, var is a variable so you
os.rename() function is causing a FileNotFoundError
I was study the import os today, I working with a rename code. and it was error due to: So I was confused with the error cause I don’t know what am I doing wrong. This is the Folder I was working with: Answer Try this: Edit:
Read out file and convert certain line into a correct form
I have a problem. I am reading in a file. This file contains abbreviations. However, I only want to read the abbreviations. This also works. However, not in the desired format as expected, I would like to save the abbreviations cleanly per line (see below for the desired output). The problem is that I’m getting something like ‘t\acro{…. How can
Reading files faster in python
I’m writting a script to read a TXT file where each line is a Log entry and I need to separate this log in different files (for all Hor, Sia, Lmu). I’m reading each line and dividing in new files with no problem when using my test file (80kb), but when I try to apply to the actual file (177MB