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
-1
votes
0 answers

How does Fread know the filepath when it isnt explicitly written R

I've picked up some old code off someone (cannot ask them directly) and they have the following code setwd(dirname(getActiveDocumentContext()$path)) dataset= fread("../Folder/excel_file.csv", stringsAsFactors = FALSE) I am wondering how fread…
MuzzMan123
  • 17
  • 4
-1
votes
2 answers

Windows 10: fopen, fread, fgets and mixed EOL characters in large text file

I am developing a program for computational material scientists: https://atomes.ipcms.fr/ Atomes can import large text files that contains atomic coordinates, to do that I read the file as a whole using fread, then split the text buffer over the CPU…
-1
votes
3 answers

why does fread from stdin not stop

I am trying to read input from stdin with fread(). However i am have a problem, the loop will not terminate and instead keeps reading. #include #include #include int main(int argc, char *argv[]) { if (argc != 2)…
-1
votes
1 answer

Best way to 'filter' user input for username

I have a site which allows users to create a 'unique URL' so they can pass along to colleagues in the form of www.site.com/customurl. I, of course, run a check to make sure the input is actually unique but I also want to filter out things like large…
JM4
  • 6,740
  • 18
  • 77
  • 125
-1
votes
1 answer

Are fread(), file() and file_get_contents() functions secure to the server when third-party external references are given as filename?

Introduction I'm asking this question because all of my findings on this topic have answers focused on the risks of variable $filename values (which I already comprehend and know the string handling requirements for secure use). I also found a…
Rafael
  • 33
  • 1
  • 8
-1
votes
2 answers

What's the difference between read and fread?

I have a question about the SO question What is the difference between read() and fread()? How do read() and fread() work? And what do unbuffered read and buffered read mean? If fread() is implemented by calling read(), why do some people say…
甚麼甚
  • 3
  • 6
-1
votes
1 answer

How do I read properly from a binary file?

I already cut my code to minimum and I think that is everything I need for my problem. I want the user to be able to read this structure: typedef struct { char movieTitle[30]; unsigned int yearPublished; char director[50]; char…
Sergej
  • 5
  • 2
-1
votes
1 answer

A Possible error in solution video of pset4 lab 'volume' within fread() function of header

This is the code from what Brian explains from cs50 week4 lab4 // Modifies the volume of an audio file #include #include #include // Number of bytes in .wav header const int HEADER_SIZE = 44; int main(int argc, char…
Annie
  • 21
  • 2
  • 10
-1
votes
1 answer

Using grep with fread() to filter rows with whitespace containing string

I'm trying to import a huge tsv file (~6.8 GB) in chunks by using R's fread() with grep to import the rows that contain the matching string in the field and then manipulating the imported datasets in some way. However, the matching string, contains…
-1
votes
1 answer

Wrong csv files being imported

I really just need another set of eyes on this code. As you can see, I am searching for files with the pattern "*45Fall...". But every time I run it, it pulls up the files "*45Sum..." and one time pulled up the "*45Win..." files. It seems totally…
-1
votes
1 answer

C freads function returns wrong file binary data

I have wrote an binary file using c and checked it using xxd with following output: 6161 6161 6161 6161 6161 6161 6161 6161 Now my Code : FILE * read; int * filebytes; read = fopen("data/myfile","rb"); fread(filebytes,4,4,read); …
qub3
  • 75
  • 7
-1
votes
2 answers

How to read contents of a file to a statically declared variable?

I have a data file in binary where the first four bytes are some integer that I want to read. I simply do: int * num_rounters_p = malloc(sizeof(int)); fread(num_rounters_p, 4, 1, p_file); printf("%d\n", *num_routers_p); // 10 This works fine (and…
Snusifer
  • 485
  • 3
  • 17
-1
votes
1 answer

Cannot get fread to read a structure array

I've been doing my project and the last thing I need to do is to save to and start reading a structure array from a file on startup of the program, but I can't figure out why the code isn't loading the information of the file. Earlier I asked a…
Levianeer
  • 13
  • 6
-1
votes
2 answers

echo text file with multiple lines in php

I want print a text file in my php code but it give me the output without multiple lines! think my txt file is this: ( name = doc.txt ) hello guys! we are here Lemon is with You! now my code is:
Babak Majdy
  • 55
  • 1
  • 7
-1
votes
1 answer

R fread() error when executing multiple scripts

edit: the file path i am giving is not /tmp/... the file path is in the form of: Erfurt/phased_edited_all_chr.gz i think the tmp directory is created by Slurm, but not sure about it. end edit. I am working on a data analysis project, and have a…
1 2 3
99
100