save

Save input as text file in python

Save input as text file in python Question: I got a simple python code with some inputs where a user has to type name, age, player name and his best game. Now I want that all these inputs from the user were saved as a text file or something like this. I tried with open …

Total answers: 3

Trigger action when manually stopping Python script

Trigger action when manually stopping Python script Question: I was searching for quite some time but I was unable to find a simple solution. I have a python script that runs indefinitely and saves some files when a condition is met (enough data gathered). Is there a way to terminate the execution of the script …

Total answers: 1

export list of arrays to txt file in python

export list of arrays to txt file in python Question: I have a list of arrays that I want to export as a txt file. x = [[np.array([0, 0, 0]), np.array([1,2,2])], [np.array([0, 0, 0]), np.array([4,5,6])]] desired output shape: (0,0,0),(1,2,2) (0,0,0),(4,5,6) I tried to use all the following methods but I didn’t get the same thing …

Total answers: 1

How to store randomly generated lists in python

How to store randomly generated lists in python Question: I am a mathematician with limited programming experience, but am building a neural network to generate curves with certain properties. I’ve built a training set which looks like a list of 1000 randomly generated numbers between -1 and 1 as follows: import random N = 1000 …

Total answers: 3

Save html to file to work with later using Beautiful Soup

Save html to file to work with later using Beautiful Soup Question: I am doing a lot of work with Beautiful Soup. However, my supervisor does not want me doing the work "in real time" from the web. Instead, he wants me to download all the text from a webpage and then work on it …

Total answers: 3

Saving Custom Model cannot be done with `model.save()`

Saving Custom Model cannot be done with `model.save()` Question: My python version 3.6.5 tensorflow version 2.3.0 Simple Custom Model import tensorflow as tf import tensorflow.keras as keras class x(keras.layers.Layer): def build(self, input_shape): self.add_weight() inputs = keras.layers.Input(1) outputs = x()(inputs) model = keras.models.Model(inputs, outputs) model.save("temp_model") And it fails with AttributeError: ‘NoneType’ object has no attribute ‘replace’ …

Total answers: 2

How can I only use Github to save versions of my code as I continuously develop?

How can I only use Github to save versions of my code as I continuously develop? Question: I am a single developer that creates python programs to automate my work. I often update the code as work duties change or I find improvements. I want to have a cloud-based version control like Github but I …

Total answers: 4

How to save each ligand from a PDB file separately with Bio.PDB?

How to save each ligand from a PDB file separately with Bio.PDB? Question: I have a list of PDB files. I want to extract the ligands of all the files (so, heteroatoms) and save each one separately into PDB files, by using the Bio.PDB module from BioPython. I tried some solutions, like this one: Remove …

Total answers: 1

How do I use Python PIL to save an image to a particular directory?

How do I use Python PIL to save an image to a particular directory? Question: For example I want to manipulate some image and then save it to a particular directory. How do I save to a specific directory other than the one I am in? I understand that this will save to the directory …

Total answers: 3

save numpy array in append mode

save numpy array in append mode Question: Is it possible to save a numpy array appending it to an already existing npy-file — something like np.save(filename,arr,mode=’a’)? I have several functions that have to iterate over the rows of a large array. I cannot create the array at once because of memory constrains. To avoid to …

Total answers: 7