fread

How to interrupt a fread call?

南楼画角 提交于 2019-12-19 18:53:58
问题 I have the following situation: There is a thread that reads from a device with a fread call. This call is blocking as long as there is no data send from the device. When I stop this thread it remains hanging inside this thread. Now I found the following inside the man page of fread: ERRORS On all systems that conform to the Single UNIX Specification, the fread() function sets errno as listed for the following conditions: [EINTR] The read operation was terminated due to the receipt of a

Importing binary LabVIEW files with header information into MATLAB?

心不动则不痛 提交于 2019-12-19 10:43:09
问题 I have large .bin files (10GB 60GB) that I want to import to MATLAB; each binary file represents the output of two sensors, thus there are too columns of data. Here is a more manageable sized example of my data. You will notice that there is a .txt version of the data; I need to upload the .bin files directly to MATLAB, I can't use the .txt version because it takes hours to convert with larger files. The problem I have is that the .bin file has header information that I can't seem to

Quickest way to read a subset of rows of a CSV

梦想与她 提交于 2019-12-19 04:07:04
问题 I have a 5GB csv with 2 million rows. The header are comma separated strings and each row are comma separated doubles with no missing or corrupted data. It is rectangular. My objective is to read a random 10% (with or without replacement, doesn't matter) of the rows into RAM as fast as possible . An example of a slow solution (but faster than read.csv ) is to read in the whole matrix with fread and then keep a random 10% of the rows. require(data.table) X <- data.matrix(fread('/home/user/test

What is “short item count” in fread()?

心不动则不痛 提交于 2019-12-18 15:54:32
问题 When I was 'man fread', I got this: RETURN VALUE fread() and fwrite() return the number of items successfully read or written (i.e., not the number of characters). If an error occurs, or the end- of-file is reached, the return value is a short item count (or zero). fread() does not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred. So my question is to how to understand "short item count". Please bear with my English. Why here

ifstream.eof() - end of file is reached before the real end

不打扰是莪最后的温柔 提交于 2019-12-18 13:16:19
问题 I have a roughly 11.1G binary file where stores a series of the depth frames from the Kinect. There are 19437 frames in this file. To read one frame per time, I use ifstream in fstream but it reaches eof before the real end of the file. (I only got the first 20 frames, and the function stops because of the eof flag) However, all frames can be read by using fread in stdio instead. Can anyone explain this situation? Thank you for precious time on my question. Here are my two functions: //

What is the equivalent of 'fread' from Matlab in Python?

不羁岁月 提交于 2019-12-18 12:26:29
问题 I have practically no knowledge of Matlab, and need to translate some parsing routines into Python. They are for large files, that are themselves divided into 'blocks', and I'm having difficulty right from the off with the checksum at the top of the file. What exactly is going on here in Matlab? status = fseek(fid, 0, 'cof'); fposition = ftell(fid); disp(' '); disp(['** Block ',num2str(iBlock),' File Position = ',int2str(fposition)]); % ----------------- Block Start ------------------ % [A,

fread and a quoted multi-line column value

巧了我就是萌 提交于 2019-12-18 08:46:10
问题 > fread('col1,col2\n') Empty data.table (0 rows) of 2 cols: col1,col2 > fread('col1,col2\n5,4') col1 col2 1: 5 4 > fread('col1,col2\n5,"4\n3"') Error in fread("col1,col2\n5,\"4\n3\"") : Unbalanced quote (") observed on this line: 3" > read.csv can import this csv as long as the value that spans multiple lines is wrapped in quotes. Should fread be able to import it as well? Using read.csv is actually fine for my use case. I can just convert the resulting data frame into a data table. But I

reading a block of lines in a file using php

那年仲夏 提交于 2019-12-18 07:12:10
问题 Considering i have a 100GB txt file containing millions of lines of text. How could i read this text file by block of lines using PHP? i can't use file_get_contents(); because the file is too large. fgets() also read the text line by line which will likely takes longer time to finish reading the whole file. If i'll be using fread($fp,5030) wherein '5030' is some length value for which it has to read. Would there be a case where it won't read the whole line(such as stop at the middle of the

'Embedded nul in string' when importing large CSV (8 GB) with fread()

余生长醉 提交于 2019-12-18 07:05:35
问题 I have a large CSV file (8.1 GB) that I'm trying to wrangle into R. I created the CSV using Python's csvkit in2csv , converted from a .txt file, but somehow the conversion led to null characters showing up in the file. I'm now getting this error when importing: Error in fread("file.csv", nrows = 100) : embedded nul in string: 'ÿþr\0e\0c\0d\0_\0z\0i\0p\0c\0' I am able to import small chunks just fine with read.csv though, but that's because it allows for UTF-16 encoding via the fileEncoding

Unsuccessful fread() of int stored in binary file, segmentation fault [closed]

自古美人都是妖i 提交于 2019-12-17 02:04:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . There seem to be of the order of 10 questions and (mostly) successful answers solving segmentation faults cause by misused fread()'s in C. That being said, I am having such a problem but have not found a solution. I have a binary file containing an int (call it nbins ) and an array of float s (of size nbins ).