Questions tagged [file-writing]

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

932 questions
3
votes
2 answers

Ordering a File from highest number to lowest, retaining the other information

I'm looking for a way to be able to read a file and rewrite the same file but taking into account all the information inside it to order it from highest to lowest /*Scores*/ Mathew: 540 Stacy: 070 Andre: 761 Alfred: 340 So that…
Box
  • 91
  • 6
3
votes
1 answer

Why am I only writing 28,672 bits to this file?

I have been working on a project where it is necessary to program a binary file, of a certain kind, to a AT28C256 chip. The specifics are not important beyond the fact that the file needs to be 32,768 bytes in size (exactly). I have some "minimal…
Isky Mathews
  • 250
  • 1
  • 10
3
votes
2 answers

In 'r+', why is that writing a textfile *after* reading a single line makes it write at the end, instead of the `f.tell()` position?

Having a text file like this: line one line two line three And running the following code: with open('file', 'r+') as f: print(f.tell()) print(f.readline().strip()) print(f.tell()) # f.seek(f.tell()) f.write('Hello') …
M I P A
  • 63
  • 1
  • 6
3
votes
2 answers

FileWriter somehow write in chinese

Please help me with this problem. I'm trying to write a code that read a .txt file and then it would count the frequencies of each letter in the file. This is what I came up with : public static void charCount(String file) throws IOException { …
3
votes
1 answer

How to write logging messages to a file

I am trying to use the Python logging library. Instead of printing the messages in the console, I want to write them to a file. Based on the documentation , I'm a little unsure of how to do this. First I imported the logging in and then I created my…
gwydion93
  • 1,681
  • 3
  • 28
  • 59
3
votes
3 answers

What are the recommended alternatives to the comma separator

I need to write my program output to a file. However, some of the fields already contain spaces, commas, semicolons, tabs. So I do not want to use spaces, tabs, commas as a field separator. The data are from the web so there are possibilities of…
user9371654
  • 2,160
  • 16
  • 45
  • 78
3
votes
2 answers

Dynamically writing to text file based on received dictionary information

I am trying to write jobs to a text file based on dictionary information. The dictionary information is received from the server and is not always the same. It contains file_count and file_paths which the file_paths is a list. e.g, {'file_paths':…
lion_bash
  • 1,309
  • 3
  • 15
  • 27
3
votes
1 answer

write to file on a remote server in python

Is there any way to write to a file which is located on another server? I have access to a powerful server with lots of resources (CPU,GPU,RAM, etc) to execute complicated python code but the amount of storage is very limited (less than 1GB). On…
3
votes
1 answer

Program is delayed in writing to a .txt file?

So, I've searched around stackoverflow for a bit, but I can't seem to find an answer to this issue. My current homework for my CS class involves reading from a file of 5000 random numbers and doing various things with the data, like putting it into…
elkshadow5
  • 369
  • 2
  • 4
  • 17
3
votes
1 answer

'\b' to produce backspace not working in fprintf to txt file (MATLAB)

I am trying to make a text file with the contents of a cell array. Below is a MWE. When I use fprintf without the file argument (to just print in the command window, e.g., fprintf(['\t\\hline ',repmat('%s & ',1,size(A,1)),'\b\b','\\\\','\n'],A{:})),…
Rodrigues
  • 143
  • 1
  • 5
3
votes
2 answers

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 or more columns that can be read later for further usage. I have created successfully a reading project but for the writing one the file is created but it is…
Learn1
  • 45
  • 1
  • 1
  • 4
3
votes
2 answers

Write list variable to file

I have a .txt file of words I want to 'clean' of swear words, so I have written a program which checks each position, one-by-one, of the word list, and if the word appears anywhere within the list of censorable words, it removes it with…
oisinvg
  • 592
  • 2
  • 8
  • 21
3
votes
2 answers

Python logging vs. write to file

Which is more efficient? Is there a downside to using open() -> write() -> close() compared to using logger.info()? PS. We are accumulating query logs for a university, so there's a perchance that it becomes big data soon (considering that the…
anobilisgorse
  • 906
  • 2
  • 11
  • 25
3
votes
2 answers

writing byte[] to file giving corrupt file

I am getting byte[] in request parameter in servlet which I am fetching in string and then again converting it into byte[] : String encodingScheme = "UTF-8"; request.setCharacterEncoding(encodingScheme); String requestStr =…
samir
  • 339
  • 6
  • 19
3
votes
1 answer

PHP - Read and write the same file hangs

I'm trying to use FFMPEG to make some works with video on the server, and something I need to do is to get the progress of the process. I searched a little and I found this solution which tells to write the log into a file and then reading and…
Unapedra
  • 2,043
  • 4
  • 25
  • 42