FAQ Database Discussion Community


Erlang, how can I create text file with newlines?

file,erlang,newline,writefile,erl
Somebody knows how can I append a new line in the text file in Erlang language? I want to save this list: Data = ["one", "two", "three"], into the text file with new lines: one two three I tried: write() -> Data = ["1","2","3"], Print = string:join(Data, "\n"), file:write_file("/Documents/foo.txt", [Print])....

WriteFile throws Access Violation when 4th (optional) parameter is NULL

c++,winapi,visual-studio-2008,access-violation,writefile
Thought that it may be helpful to someone because it was a kind of surprise for me. WriteFile function tries to write into its 4th (optional) parameter, and if it is NULL it causes Access Violation exception... But not on Windows 8(.1). This is the function definition from msdn: BOOL...

Why does WriteFile not run more than once?

c++,winapi,writefile
Here's my code in which I've got on an infinite loop (to my knowledge) while(true) { DWORD TitleID = XamGetCurrentTitleId(); std::ostringstream titleMessageSS; titleMessageSS << "Here's the current title we're on : " << TitleID << "\n\n"; std::string titleMessage = titleMessageSS.str(); // get the string from the stream DWORD dwBytesToWrite =...

Don't write text into my txt file

java,readfile,writefile
With this code I want to read one text file, put all elements into a arraylist and replace the file with the the arraylist contain. But this code don't write into file and I don't know why... public void delete(String lineToDelete, String nameFile) throws IOException { file = new File(nameFile);...

How to make sure data is flushed to HDD (not buffered) on file IO (WriteFile())

c++,c,file-io,writefile
During a lengthy and possibly system stressful operation I update a file from time to time via a File Handle and WriteFile I noticed that when I right mouse click the file and ask for its properties in Windows I don't see it has been updated at all. The Modified...

Python append json to json file in a while loop

python,json,python-requests,github-api,writefile
I'm trying to get all users information from GitHub API using Python Requests library. Here is my code: import requests import json url = 'https://api.github.com/users' token = "my_token" headers = {'Authorization': 'token %s' % token} r = requests.get(url, headers=headers) users = r.json() with open('users.json', 'w') as outfile: json.dump(users, outfile) I...

Write multiple lists to text file in python - 2.7

python,text,writefile
originally the lists was nested within another list. each element in the list was a series of strings. ['aaa664847', 'Completed', 'location', 'mode', '2014-xx-ddT20:00:00.000'] I joined the strings within the list and then append to results. results.append[orginal] print results ['aaa664847, Completed, location, mode, 2014-xx-ddT20:00:00.000'] ['aaa665487, Completed, location, mode, 2014-xx-ddT19:00:00.000'] ['aaa661965, Completed,...

Android read/write local file (NullPointerException)?

java,android,nullpointerexception,writefile
I'm using simple code for read/write oneLine string to local file. And it works well, until I put Read/write_file_operations in another class. Now this code get null pointer exception, I think something wrong with Context, but I don't know what... MainActivity.java import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import...

Looking for a way to speed up the write to file portion of my Python code

performance,python-3.x,readfile,writefile
I have a simple code that reads in a data file ~2Gb, extracts the columns of data that I need and then writes that data as columns to another file for later processing. I ran the code last night and it took close to nine hours to complete. I ran...