Top "File-writing" questions

This tag refers to the process of writing text or data to a file.

How do I specify new lines on Python, when writing on files?

In comparison to Java (in a string), you would do something like "First Line\r\nSecond Line". So how would …

python line-breaks file-writing
How to redirect 'print' output to a file using python?

I want to redirect the print to a .txt file using python. I have a 'for' loop, which will 'print' …

python-2.x file-writing
Writing a dictionary to a text file?

I have a dictionary and am trying to write it to a file. exDict = {1:1, 2:2, 3:3} with open('file.txt', 'r') as …

python-3.x file dictionary file-writing
How to write the resulting RDD to a csv file in Spark python

I have a resulting RDD labelsAndPredictions = testData.map(lambda lp: lp.label).zip(predictions). This has output in this format: [(0.0, 0.08482142857142858), (0.0, 0.11442786069651742),.....] …

python csv apache-spark pyspark file-writing
How to remove \n and \r from a string

I currently am trying to get the code from this website: http://netherkingdom.netai.net/pycake.html Then I have …

python html python-3.x file-writing
Using "with open() as file" method, how to write more than once?

Usually to write a file, I would do the following: the_file = open("somefile.txt","wb") the_file.write("telperion") …

python file with-statement file-writing
How do I write to a file in Kotlin?

I can't seem to find this question yet, but what is the simplest, most-idiomatic way of opening/creating a file, …

kotlin file-writing
Delete the contents of a file before writing to it (in Python)?

I'm trying my hand at this rosalind problem and am running into an issue. I believe everything in my code …

python overwrite file-writing
Write to a file with sudo privileges in Python

The following code throws an error if it's run by a non-root user for a file owned by root, even …

python file-writing ioerror
Writing Integers to a .txt file in c++

I am new to C++ and want to write data(integers) on a .txt file. The data is in three …

c++ fstream ofstream file-writing