Questions tagged [file-writing]

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

932 questions
-2
votes
1 answer

How to write this new file completing with information inside a string in the correct positions?

If I have this string, it contains several lines separated by newlines. data_string = """ te gustan los animales? puede que algunos me gusten pero no se mucho de eso animales puede que algunos me gusten pero no se mucho de eso te gustan las…
Matt095
  • 857
  • 3
  • 9
-2
votes
1 answer

How to space items?

import os s = os.listdir("qwe") f = open("asd.txt", "w") for i in range(0, 100): try: f.writelines(s[i] + ":" + "\n") f.writelines(os.listdir("qwe\ ".strip() + s[i] + "\Wallets")) f.writelines("\n" + "\n") except: …
-2
votes
3 answers

How to write to a file in python without adding a new line except at certain place?

I want to write to a file without adding a new line at the iterations of a for loop except the last one. Code: items = ['1','2','3'] with open('file.txt', "w") as f: f.write('test' + '\n') for t in items: f.write(t + '\n')#i…
Zen35X
  • 76
  • 2
  • 10
-2
votes
2 answers

Why I am getting numeric value as output when I am writing in a text file?

open_txt_file = open("codeharrytextfile.txt","w") #file point b = open_txt_file.write("test it theory") print(b) I have tried writing to existing textfile and I was expecting it to display the updated text written to it whereas I am getting value…
-2
votes
1 answer

What is a fast async text writer that can be used to log a line of text to a csv file?

I am trying to find a text writer that will not block it's calling thread. It will be called over 400k times a day and will be used for logging lines of text to a csv file. Here is what I have come up with so far: public void callWriter() …
Alexander
  • 3
  • 2
-2
votes
1 answer

C# Process File Access Denied

While writing a file in a single thread application, I get the error "The process cannot access the file because it is being used by another process". I open all writer objects in the using keyword. Although it is a single thread, I lock functions…
-2
votes
1 answer

How can I save my html parsed data as a CSV file?

I have made all the necessary imports (Jsoup Elements and Element) and the code runs well. I am a beginner and couldn't make the file export properly as a CSV. The data either stays on the same row or the same column. Document document =…
-2
votes
1 answer

json.dump doesn't dump anything, and leaves me with an empty file | Python

I have been trying to dump a dictionary into my JSON file with the json library. However, when I dump, the file doesn't show anything inside it. Furthermore, when I read the file (using open('file').read()), it shows the data there! Can anyone help…
coderman1234
  • 210
  • 3
  • 12
-2
votes
2 answers

Code in python that writes more than one text-file

I have started with a code that is intended to write many textfiles by first reading one textfile. More details of question after the started code. The textfile (Im reading from texfile called alphabet.txt): a b c : d e f : g h i : I want the…
user14638035
-2
votes
2 answers

How to set vertical the ouput in python?

I would like to create an output in `.txt format in python. The problem is that the results are showing horizontally. How can I set my values vertically? for example my output has the format: [6.48421466 4.28001787 6.76134729 5.45509747 7.68957008…
MRpapas
  • 23
  • 4
-2
votes
2 answers

Files are not opening nor writing through python code

Completely new and learning python, so please be patient with my noob problems lol. i tried entering this code: file = open('Test.txt','w') file.write('Hello world') After that it doesn't give me an error but also wont open nor write. The…
MrHotShot
  • 19
  • 6
-2
votes
1 answer

How to write a paragraph to an excel file, each word in new cell?

I have a corpus of around "1 million Urdu sentences" in a .txt file (notepad). I want to save each "Urdu word" in a separate cell of an excel sheet. Can some one help me with any regex or code fragment tested? I am using python pycharm. I don't…
-2
votes
2 answers

How do I create a csv file using python?

I have 7 separate parameters that I have lists for. Let's call them A, B, C, D, E, F, and G. All of these parameters will be lists of numbers. I need to make a csv file that is in this…
-2
votes
1 answer

How to write a file in WPF for Windows Screen Saver

I developed a custom screen saver in WPF (with the extension .scr) but I got an issue : When screen saver is run by Windows, the application stop imediately. After some tests, I found that it comes from the fact that I'm creating/writing files. I…
Darkerone
  • 51
  • 5
-2
votes
2 answers

Serializing HashMap And writing Into a file

I have a HashMap which contains Set as Key and Value, HashMap, Set> mapData = new HashMap, Set>(); If I want to write this HashMap object into a file, Whats is the best way to do it. Also I want to…
Justin
  • 735
  • 1
  • 15
  • 32