ReadFile() is a Windows API function to read data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device.
Questions tagged [readfile]
2383 questions
269
votes
13 answers
How to read file with async/await properly?
I cannot figure out how async/await works. I slightly understand it but I can't make it work.
function loadMonoCounter() {
fs.readFileSync("monolitic.txt", "binary", async function(err, data) {
return await new Buffer( data);
…

Jeremy Dicaire
- 4,615
- 8
- 38
- 62
196
votes
11 answers
open read and close a file in 1 line of code
Now I use:
pageHeadSectionFile = open('pagehead.section.htm','r')
output = pageHeadSectionFile.read()
pageHeadSectionFile.close()
But to make the code look better, I can do:
output = open('pagehead.section.htm','r').read()
When using the above…

1qazxsw2
- 2,589
- 4
- 20
- 19
137
votes
6 answers
Skip rows during csv import pandas
I'm trying to import a .csv file using pandas.read_csv(), however, I don't want to import the 2nd row of the data file (the row with index = 1 for 0-indexing).
I can't see how not to import it because the arguments used with the command seem…

thosphor
- 2,493
- 7
- 26
- 42
117
votes
4 answers
ReadFile in Base64 Nodejs
I'm trying to read an image from client side encoded in base64.
How to read with nodejs?
My code:
// add to buffer base64 image
var encondedImage = new Buffer(image.name, 'base64');
fs.readFile(encondedImage, "base64", function(err, buffer){
if…

brunocascio
- 1,867
- 3
- 14
- 21
70
votes
4 answers
Reading two text files line by line simultaneously
I have two text files in two different languages and they are aligned line by line. I.e. the first line in textfile1 corresponds to the first line in textfile2, and so on and so forth.
Is there a way to read both file line-by-line simultaneously?…

alvas
- 115,346
- 109
- 446
- 738
50
votes
1 answer
Is it possible to read categorical columns with pandas' read_csv?
I have tried passing the dtype parameter with read_csv as dtype={n: pandas.Categorical} but this does not work properly (the result is an Object). The manual is unclear.

Emre
- 5,976
- 7
- 29
- 42
49
votes
2 answers
readFileSync is not a function
I am relatively new to Node.js and have been looking around but cannot find a solution. I did check the require javascript file and it does not seem to have a method for "readFileSync". Perhaps I don't have a proper require file? I had a hard time…

L1ghtk3ira
- 3,021
- 6
- 31
- 70
49
votes
1 answer
PHP readfile vs. file_get_contents
I have used following code to generate zip
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
this code works fine but for unknown reasons…

justnajm
- 4,422
- 6
- 36
- 56
47
votes
7 answers
Using Promises with fs.readFile in a loop
I'm trying to understand why the below promise setups don't work.
(Note: I already solved this issue with async.map. But I would like to learn why my attempts below didn't work.)
The correct behavior should be: bFunc should run as many time as…

David
- 494
- 1
- 4
- 11
45
votes
4 answers
How to read text file in react
Screenshot1
Screenshot2
I want to read from a text file within the react project, but when I try to execute and read I get a HTML sample code in the console log.
This is the function:
onclick= () =>{
fetch('data.txt')
.then(function(response){
…

Salvadore Rina
- 559
- 1
- 4
- 7
45
votes
6 answers
Where to place a .txt file and read from it in a IOS project
i want to put a .txt file in my Xcode Swift Iphone project.
First, i simply drag&dropped it from my desktop to the Supporting Files Folder from the project. Isn't there a Folder like on Android "assets", so i can place my files anywhere i want?
The…

Felix Me
- 481
- 1
- 4
- 10
44
votes
2 answers
How to refactor Node.js code that uses fs.readFileSync() into using fs.readFile()?
I'm trying to get my head around synchronous versus asynchronous in Node.js, in particular for reading an HTML file.
In a request handler, the synchronous version that I'm using, which works is the following:
var fs = require("fs");
var…

Bondifrench
- 1,272
- 1
- 20
- 35
40
votes
10 answers
Flutter: how to load file for testing
File can be read from the directory relative to the dart script file, simply as var file = new File('./fixture/contacts.json').
However the file cannot be read flutter test running inside IDE.
Loading as resource (it is not, since I do not want to…

Kyaw Tun
- 12,447
- 10
- 56
- 83
38
votes
4 answers
A Haskell function of type: IO String-> String
I wrote a bunch of code in Haskell to create an index of a text. The top function looks like this:
index :: String -> [(String, [Integer])]
index a = [...]
Now I want to give this function a String read from a file:
index readFile…

ChrisQuignon
- 685
- 1
- 6
- 9
26
votes
9 answers
Where to put a textfile I want to use in eclipse?
I need to read a text file when I start my program. I'm using eclipse and started a new java project. In my project folder I got the "src" folder and the standard "JRE System Library" + staedteliste.txt... I just don't know where to put the text…

MJB
- 3,934
- 10
- 48
- 72