Questions tagged [file-read]

This tag can be used on questions about reading files.

To work with stored data, file handling belongs to the core knowledge of every programmer. One of the core file handling methods is reading a file.

Resources:

577 questions
2
votes
6 answers

PHP Cannot Read External File

I am trying to read an external file, hosted on another server, but am having issues. Here, I identify the variables: $variable1 = "test"; $variable2 = "testing"; Here, I identify the URL to read: $url = "http://test.com/page.php?v1=" . $variable1…
Jacob
  • 21
  • 1
  • 2
2
votes
1 answer

Off-by-one errors when reading a file one chunk at a time

ifstream::readsome is notoriously bad for reading chunks of a file due to implementation-defined issues. In my case, MSVC returns 0 on a freshly opened file. I looked at their implementation and realized they're just calling ifstream::read under the…
Casey
  • 8,686
  • 9
  • 52
  • 79
2
votes
3 answers

Searching through a large text or log file (10GB+)

Part of a Python script that I'm writing requires me to find a particular string in a large text or log file: if it exists then do something; otherwise, do something else. The files which are being fed in are extremely large (10GB+). It feels…
2
votes
3 answers

Read 10 lines at a time from text file in C#

I'm looking for a solution to read 10 lines from a text files and then more 10 lines until the end of the file. This is what I started, of course it shows me the first 10 lines, but how can I repeat this process for the next 10 lines and so on,…
2
votes
1 answer

SSD read performance

In my application, It writes a large file (650GB) to an SSD. That contains large number of ~1k messages. Messages are not fixed length. Therefore I maintain an in-memory indices as required for several message filtering criteria. The index contained…
Sujith Gunawardhane
  • 1,095
  • 7
  • 19
2
votes
1 answer

Im trying to read a txt file into a linked list, that contains both integers and strings in a line, separated by commas

Im making a database, where the information about books and readers in a library are contained in two linked lists, and each line of the txt file contains the data of one book/peopleinlibrary. Data of the…
David69420
  • 21
  • 1
2
votes
1 answer

Reading a file in dart and split the string has different results in console that in vscode

I'm new in dart, I'm trying to read information from a txt file and use the data to create objects from a class (in this case about pokemon), but when I run my program in the terminal it doesn't prints the correct information, and when I run the…
2
votes
1 answer

C programming: Problems reading a filetext and trying to sort out the longest word

I am beginner at coding, so I might be doing quite a few rookie mistakes here and there. We got this task in school and the goal is to sort out the longest word and print it together with the number of characters it has. I have gotten this far but…
RobinH
  • 23
  • 3
2
votes
4 answers

How does one make an already opened file readable (e.g. sys.stdout)?

I was trying to get the contents of sys.stdout in a string. I tried the obvious: def get_stdout(): import sys print('a') print('b') print('c') repr(sys.stdout) contents = "" #with open('some_file.txt','r') as f: …
Charlie Parker
  • 13,522
  • 35
  • 118
  • 206
2
votes
1 answer

.travis.yml file should read from another file a value and use it

In my .travis.yml file I wanna read which issues is the latest at the moment in my issue file .travis.yml: env: global: - issues=$(cat "issues.txt"); matrix: include: - language: bash script: - bash…
Joergi
  • 1,593
  • 2
  • 36
  • 74
2
votes
2 answers

difference between readfile() and fopen()

These two codes both do the same thing in reading files , so what's the main difference ? 1-First code : $handle = fopen($file, 'r'); $data = fread($handle, filesize($file)); 2-Second code : readfile($file);
bradi
  • 39
  • 6
2
votes
2 answers

how to write the python "with" statement?

I have this code, which I'm supposed to write using the 'with' statement or 'with' method. If any of you have an idea of how to do it, or any initial idea for me to take I'd be grateful. def read_csv(folder_file, sep): ''' reads a csv file, …
joacokp
  • 29
  • 4
2
votes
1 answer

Reading file with POSIX read

I have a file which is dumped by the following code: for (unsigned long long i = 0; i < 10; i++) { unsigned char byte = rand() % 16; printf("%02x", byte); } I can read this file using fscanf: uint8_t *buf; uint64_t index = 0; unsigned int…
Tes
  • 299
  • 2
  • 9
2
votes
2 answers

How to convert a string to uint32_t

I have a program which reads the contents of a file line by line, stores each line into a vector of strings, and then prints the contents of the vector. After reading the file data into the vector of strings, I am attempting to convert each line…
p.luck
  • 401
  • 2
  • 6
  • 26
2
votes
1 answer

Usage of file protocol in HTTP request

Reading file using HTTP Request is suggested for Passing variables between threads. For example you could use the Save Responses to a file listener or perhaps a BeanShell PostProcessor in one thread, and read the file using the HTTP Sampler "file:"…
user7294900
  • 47,183
  • 17
  • 74
  • 157