Questions tagged [fread]

A binary-safe file read function in C/C++/PHP that returns the specified number of bytes from a stream. Also a fast csv parser in R's data.table package.

References:

1613 questions
8
votes
1 answer

append multiple large data.table's; custom data coercion using colClasses and fread; named pipes

[This is kind of multiple bug-reports/feature requests in one post, but they don't necessarily make sense in isolation. Apologies for the monster post in advance. Posting here as suggested by help(data.table). Also, I'm new to R; so apologies if I'm…
James
  • 630
  • 1
  • 6
  • 15
8
votes
2 answers

R data.table fread from clipboard

I want to create an interface excel-R::data.table. I would like to ask how it is possible to use fread function with clipboard. Following code is working well but I would prefer to use fread instead of read.table (to reproduce copy some table in…
jangorecki
  • 16,384
  • 4
  • 79
  • 160
8
votes
2 answers

Using sep = "." in `fread` from "data.table"

Can fread from "data.table" be forced to successfully use "." as a sep value? I'm trying to use fread to speed up my concat.split functions in "splitstackshape". See this Gist for the general approach I'm taking, and this question for why I want to…
A5C1D2H2I1M1N2O1R2T1
  • 190,393
  • 28
  • 405
  • 485
8
votes
2 answers

Reading data from fsockopen using fgets/fread hangs

Here is the code that I am using: if (!($fp = fsockopen('ssl://imap.gmail.com', '993', $errno, $errstr, 15))) echo "Could not connect to host"; $server_response = fread($fp, 256); echo $server_response; fwrite($fp, "C01…
victor_golf
  • 195
  • 2
  • 2
  • 10
7
votes
3 answers

How do I disable buffering in fread()?

I am reading and writing to sockets using fread() and fwrite(). These functions, I believe are for buffered input and output. Is there some way that I can disable buffering while still using these functions ? Edit : I am building a remote desktop…
AnkurVj
  • 7,958
  • 10
  • 43
  • 55
7
votes
3 answers

C fread() magically reading dynamically allocated struct members, how?

This is a test program that I have written for a larger project that I am working on. It has to do with writing struct data to disk with fwrite() and then reading that data back with fread(). One member of the struct is dynamically allocated. …
tsliwkan
  • 141
  • 2
  • 10
7
votes
3 answers

fread Function in C Programming

I have two questions about C's fread function: I have read that fread is used to read a binary file. However, when I read a binary file with fgets using read mode "r" and a text file with fread using "rb" mode, the results are the same as reading…
mainajaved
  • 7,905
  • 10
  • 36
  • 44
7
votes
2 answers

Safe maximum number of records read by fread

I am using fread to read a large chunk of image data (> 1 MB) from a file. I recently encountered a bug on MinGW with Windows network shares where a single call to fread like fread(file, 4, 100000, data); fails reliably with an "Invalid argument"…
thiton
  • 35,651
  • 4
  • 70
  • 100
7
votes
1 answer

Last line of csv file is not read by fread from package data.table with error message 'Discarded single-line footer'

I have a csv file that has windows line endings (CR LF) and is separated by semicolon. The last line in the file is an empty line, i.e. no semicolons contained or any other character. When reading the file with fread from the data.table package the…
Oliver
  • 312
  • 2
  • 9
7
votes
2 answers

fread and ferror don't set errno

I'm trying to check when fread() raises an error, so I use ferror(). chunk = fread(buf, 1, 100, file); if (ferror(file)) { return errno; } But, ferror() man page (man 3 ferror, or just man ferror) says: ERRORS These functions should not…
Mahmoud Mubarak
  • 139
  • 1
  • 11
7
votes
4 answers

R: How can I read a CSV file with data.table::fread, that has a comma as decimal and point as thousand separator="."

I got several CSV files which contain numbers in the local german style i.e. with a comma as the decimal separator and the point as the thousand separator e.g. 10.380,45. The values in the CSV file are separated by ";". The files also contain…
PhiSeu
  • 301
  • 2
  • 9
7
votes
5 answers

Does fread fail for large files?

I have to analyze a 16 GB file. I am reading through the file sequentially using fread() and fseek(). Is it feasible? Will fread() work for such a large file?
bcubed
  • 139
  • 1
  • 4
7
votes
2 answers

How to handle Coverity error TAINTED_SCALAR in fread

While reading a value from file for an integer, coverity check is giving following error Calling function "fread" taints argument "readval" //coverity note: Calling function "fread" taints argument "readval". if(fread(&readval, sizeof(int), 1, fp) <…
coder
  • 71
  • 1
  • 1
  • 2
7
votes
2 answers

Is it possible to direct fread within data.table package to skip erroneous rows

data.table 1.9.2 I'm reading in a large table and there appears to be at least one row which produces an error of the following nature: Error in fread(paste(base_dir, filename, sep = "")) : Expected sep ('|') but '' ends field 23 on line 190333…
bibzzzz
  • 193
  • 1
  • 10
7
votes
2 answers

A C# equivalent of C's fread file i/o

Can anyone tell me how to get a array of bytes into a structure in a direct fashion in C# .NET version 2? Like the familiar fread as found in C, so far I have not had much success in reading a stream of bytes and automatically filling a structure. I…
t0mm13b
  • 34,087
  • 8
  • 78
  • 110