Questions tagged [readfile]

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.

2383 questions
15
votes
1 answer

ifstream::read doesn't tell how many bytes it really reads?

I'm using ifstream::read to read a file, ifstream ifs("a.txt"); char buf[1024]; ifs.read(buf, 1024); But a.txt's size might be less than 1000 bytes, so how am I supposed to know how many bytes have been read from ifs?
Alcott
  • 17,905
  • 32
  • 116
  • 173
13
votes
1 answer

how can i access logcat file on device

How can I access and read the logcat file (at "/system/bin/logcat") from the device, using my application. My phone is not rooted. Do I need a super user permission?
user975349
  • 173
  • 2
  • 6
13
votes
4 answers

How to turn a file into a string in NodeJS

I am attempting to convert a text file (on my machine) into a string. What is the best/simplest way to do this? I am looking for a basic function that would look like this: function fileToString(filepath) { //this returns a string with the…
Moish
  • 452
  • 1
  • 3
  • 13
13
votes
2 answers

PHP readfile() of external URL

Can I use external URLs in readfile()? header('Content-type: application/pdf'); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: inline; filename="'.$file.'" '); //header('Content-Length: ' .…
user583311
  • 265
  • 3
  • 6
  • 13
13
votes
2 answers

Reading a file and then overwriting it in Python

I've been trying to read a file and then overwrite it with some updated data. I've tried doing it like this: #Created filename.txt with some data with open('filename.txt', 'r+') as f: data = f.read() new_data = process(data) # data is being…
pystudent
  • 531
  • 1
  • 5
  • 19
12
votes
3 answers

what is the use of fs.open() in nodejs, what is difference between fs.readfile and fs.open()

I want to know what is the use of fs.open() in nodejs application. What is the difference between the open and readfile methods in nodejs, and how do they work?
Venkat Ch
  • 696
  • 1
  • 5
  • 16
12
votes
1 answer

Open local file in electron and render in wavesurfer.js

I'm working on an app built with electron, it should work with wavesurfer.js to display a waveform representing the audio file. However, I'm having trouble opening the file using the fs module and pushing the file content to wavesurfer via a Blob.…
mspae
  • 276
  • 4
  • 13
11
votes
2 answers

Read multiple lines from a file batch by batch

I would like to know is there a method that can read multiple lines from a file batch by batch. For example: with open(filename, 'rb') as f: for n_lines in f: process(n_lines) In this function, what I would like to do is: for every…
fluency03
  • 2,637
  • 7
  • 32
  • 62
11
votes
6 answers

@readfile in php?

I hate that google can not search for symbols. I saw this in some sample code and wondered why there is an @ sign before the readfile function: @readfile($filename); What does it mean different to without an @ symbol?
Jonathan.
  • 53,997
  • 54
  • 186
  • 290
11
votes
4 answers

how to parse a config file (*.conf) in shell script?

I am new to shell script. I have a file app.conf as : [MySql] user = root password = root123 domain = localhost database = db_name port = 3306 [Logs] level = logging.DEBUG [Server] port = 8080 I want to parse this file in shell script and want to…
exAres
  • 4,806
  • 16
  • 53
  • 95
11
votes
6 answers

The fastest way to read input in Python

I want to read a huge text file that contains list of lists of integers. Now I'm doing the following: G = [] with open("test.txt", 'r') as f: for line in f: G.append(list(map(int,line.split()))) However, it takes about 17 secs (via…
Sergey Ivanov
  • 3,719
  • 7
  • 34
  • 59
10
votes
4 answers

read file from external storage

I simply cannot find how to get one specified file from the external storage. I know that with getExternalStoragePublicDirectory(), you get the external storage directory but I can't get further. I need some kind of method where you have to give…
Kat
  • 668
  • 2
  • 11
  • 24
10
votes
3 answers

Nestjs readFileSync return Cannot read property 'readFileSync' of undefined

I trying get file using method readFileSync: import fs from 'fs'; import path from 'path'; const templateFile = fs.readFileSync( path.resolve( __dirname, '../mail/templates/exampleTemplate.html', ), 'utf-8', ); Nest still…
michal
  • 1,534
  • 5
  • 28
  • 62
10
votes
1 answer

Getting "title already used as a name or title" error while reading SPSS (.sav) file in Python

I've working on reading an SPSS file (.sav). My code below can read .sav files. However, I've encounter a very strange error. When I try to read another .sav file, it gives the following error Traceback (most recent call last): File…
user3288051
  • 574
  • 1
  • 11
  • 28
10
votes
1 answer

createReadStream in Node.JS

So I used fs.readFile() and it gives me "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory" since fs.readFile() loads the whole file into memory before calling the callback, should I use fs.createReadStream() instead?…
user3421904