All Questions
Tagged with writetofile python
37
questions
0
votes
0answers
12 views
How to loop through dbf files, convert dbf to dataframe, and write out separate output for each file in list of files?
I need to loop through dbf files (from ArcGIS), convert to dataframe, sort, concatenate with another dataframe, then write a unique file from the result of the operations performed in the for loop. ...
0
votes
1answer
40 views
How I write exceptions in python if no results are found when looking up information?
I am looping over a data frame with a for loop entering in information. Each time information is entered. Name and id. The database will return the information if it exists else nothing will be ...
0
votes
5answers
138 views
What is the most efficient way to repeatedly search a large text file (800 MB) for certain numbers?
The large file is 12 million lines of text such as this:
81.70, 89.86, 717.985
81.74, 89.86, 717.995
81.78, 89.86, 718.004
81.82, 89.86, 718.014
81.86, 89.86, 718.024
81.90, 89.86, 718....
0
votes
0answers
20 views
Writing to file: number of lines doesn't match
neighbors_to_file is supposed to write each triangle face's neighbors into the file neigh.txt, separated by a new line. The number of faces in this mesh is 352169, therefore the expected number of ...
0
votes
0answers
27 views
Python writes questions instead of string to file
I want to write data from API to file, but i get weird characters written to file instead of string
import requests
end_url = url `+ "?key=" + api_key + "&lang=en-ru" + "&text=" + "Hello
...
0
votes
2answers
75 views
Is there a simple way to write multiple lines to a text file?
I'm writing this bookstore program that reads a text file, you place your order, and then it writes your receipt to a different text file. I wrote the whole thing forgetting I needed to write the ...
-2
votes
1answer
45 views
Issues printing to a CSV in Python
For work I've made a very very basic UI that when a btn is clicked, it generates users using a web service. I want to be able to write these user details into a csv, but I'm struggling. Could someone ...
-1
votes
2answers
62 views
Creating A Password Manger In Python But It Is Not Writing To File
I am trying to create a password manager in python with tkinter. But when I try to write the account name, username and password it doesn't work. I am using a text box with StringVar to get the info ...
0
votes
0answers
345 views
Python writing scientific notation to file; how do I write to file in decimal? [duplicate]
I've got a long list of numbers in a one-column csv file, and I am running the following code (the backbone of which was kindly offered by @jpp) to generate a ranked list of the most frequent ...
1
vote
1answer
2k views
How to write a pandas dataframe to CSV file line by line, one line at a time?
I have a list of about 1 million addresses, and a function to find their latitudes and longitudes. Since some of the records are improperly formatted (or for whatever reason), sometimes the function ...
0
votes
2answers
2k views
How to write data to a text file in Flask? [duplicate]
Our goal is to write a variable called "inputed_email" into a text file named "test3.txt". Because this takes place on the server, we need to make sure that this Python script can access the directory ...
2
votes
1answer
1k views
Writing dictionary of dataframes to file
I have a dictionary, and for each key in my dictionary, I have one pandas dataframe. The dataframes from key to key are of unequal length.
It takes some time to get to the dataframes that are ...
0
votes
1answer
44 views
Python - Filelisting, duplicate results
I am new to Python and trying to make a script that reads a DIR and returns that DIR in a .txt file.
My code is:
import os
from os import walk
rootdir = "C:\\PythonTesting\\dirReader\\test"
...
-1
votes
1answer
990 views
How to write 'utf-8' to a new CSV file using python3 with Anaconda?
How to write 'utf-8' to a new CSV file using python3 with Anaconda?
I'm a new python and pandas learner. The version I use is python3. I run it with Anaconda platform, an IDE as similar as PyCharm ...
0
votes
0answers
56 views
Printing to screen and writing to file
I found a solution for writing to file what prints to the screen...
import sys
global saveFile
saveFile = open((fileName)+'.txt','w')
sys.stdout = saveFile
print("THIS QUOTE HAS BEEN BROUGHT TO YOU ...
0
votes
5answers
55 views
Creating and writing to file - Python
I want to create a file with a name according to a variable. That is my first problem and then I want to write what is printed to the screen in console to that file.
This is what I have, I am ...
0
votes
1answer
457 views
writing uint16 Raw files
I try to write a raw file with the following code:
OutputFile = open(OutputFilePath,'w')
BlockArray= np.array(A).astype(np.uint16)
BlockArray.tofile(OutputFile)
OutputFile.close()
Then I try to read ...
-3
votes
1answer
88 views
Send all file output to a text file
I have the below, along with several f.write commands in my python, but I can't figure out how to get it to print/catch errors to the same file.
f=open("C:/path/to/file/log.text","a+")
Also, how ...
-7
votes
1answer
36 views
I am searching for a way to save and read a file easily in python 3.5.2 (It doesn't need to be readable by humans.)
I am needing help with this as i am using it in part of my test and i would also like to use it to create a save file for a python game.
1
vote
0answers
77 views
Write to file from dictionary instead of pandas
I would like to print dictionaries to file in a different way.
Right now, I am using Pandas to convert dictionaries to Dataframes, combine several Dataframes and then print them to file (see below ...
0
votes
1answer
138 views
Writing to a file in python
The following is the code
import sys
print "Enter '1' to upload a file." +'\n'
print "Enter '2' to download a file." +'\n'
print "Enter '3' to view the contents of a file" +'\n'
print "Enter '4' to ...
0
votes
2answers
39 views
Writing into csv file would export in excel wrong
i have a problem with writing into a csv file. First the "lists" in the code would return a list that has the usernames with a lot of gaps and does not show properly. Secondly once I try to write it ...
5
votes
2answers
3k views
How to write numpy arrays to .txt file, starting at a certain line?
I need to write 3 numpy arrays into a txt file. The head of the file looks like that:
#Filexy
#time operation1 operation2
The numpy arrays look like the following:
time = np.array([0,60,120,180,......
1
vote
1answer
9k views
python, write the contents of a list to a text file
I created a program in python that is used to create/edit user generated lists. I tried to create a save function that will save a list to a text file, but I'm having a problem. It will create the ...
0
votes
2answers
595 views
How to write to a txt file ascii characters in python?
I'm implementing a XOR method, and I want to write the ciphered message to a txt file, but in the way I'm doing it, I get strange characters instead of the message.
Here is the code:
from itertools ...
2
votes
3answers
66 views
Trying to write a dictionary from file, key becomes value
I have an assessment where I have to write a full name with a score to a file, then read it back and be able to sort by either name or high score. I've worked out how to read the file into a ...
0
votes
2answers
2k views
Save selected columns of a CSV file in a new CSV file
I've got a CSV file input.csv with 10 columns:
col0, col1, col2, ..., col9
I want to copy only specific columns, in this specific order:
col0,col5,col4,col7
into a new CSV file output.csv. How ...
2
votes
3answers
3k views
Insert text in between file lines in python
I have a file that I am currently reading from using
fo = open("file.txt", "r")
Then by doing
file = open("newfile.txt", "w")
file.write(fo.read())
file.write("Hello at the end of the file")
fo....
2
votes
3answers
110 views
Exporting a dictionary to a text file in this format
I am trying to export a dictionary to a text file as shown with the code below:
user_scores = {}
with open('Class 1.txt') as f:
for line in f:
this_line = line.strip().replace("\n","")....
0
votes
0answers
171 views
Python Write To File Error: Lists
I've been trying to write two tuple lists I've created to a txt file called WorldSeriesWinnersND.txt HOWEVER, though no error messages come up when the program is run, the txt file remains unchanged. ...
0
votes
2answers
68 views
Writing to a file from a python module
I am currently trying to debug an app that I have not written myself. I have narrowed the problem down to a particular method that is imported from a module outside of the current script. I would like ...
0
votes
2answers
88 views
Is there a way of writing several lines at a time to a file in python?
I need to write a lot of information to a file, basically a whole webpage with certain values calculated using my script. I know I can do this using .write(), however I would like to know if you can ...
0
votes
3answers
1k views
Writing to an existing file without overwriting/erasing
My goal is quite simple, but I couldn't find it on the guide for configobj.
When I run my code I want it to write to a file but not erase what there's in the file already.
I would like everytime I ...
1
vote
2answers
940 views
Error while saving attachment
I am new to Python and getting an error which I am not able to get past.
Writing a code to go through my outlook and extract attachment(excel) if subject matches a given string. Here is the code:
...
1
vote
1answer
70 views
how to rearrange value order in numpy?
I have a folder with many images (ordered by their creation time) that I can read into numpy float32 arrays. I want to write these arrays down to the filesystem in a single file in two different ...
-3
votes
2answers
190 views
how to write to a text file using python ?
I am trying to output a full for iteration. The output should be in a text file. How should I code for that ?
The output should look like :
Iteration 1 values --------> val1 < tab > val2 <...
2
votes
1answer
145 views
Having trouble trying to add a line to a text file if that line doesn't exist already using Python fileinput.FileInput(…)
I'm trying to edit text files using the Python FileInput class. First I store the lines that i need to write in a Dictionary. Then I iterate through that dictionary, and if the dictionary[key] ...