Questions tagged [seek]

Seeking is the act of moving around a file or file-like object.

Seeking is the act of moving around a file or file-like object.

ANSI C in section 2.3.12.10 specifies thatfseek has the argument structure:

int fseek(FILE *stream, long offset, int whence);

Where:

  • stream is the FILE object to seek (note that this does not have to physically be a file)
  • offset is how much, relative to the whence argument
  • whence is one of
    • SEEK_SET (offset is computed relative to the start of the file)
    • SEEK_CUR (offset is computed relative to the current position)
    • SEEK_END (offset is computed relative to the end of the file)

The majority of languages based upon C, and even many that aren't, have inherited something similar to fseek, but have probably put it somewhere else (ex. Python's file.seek). Check your language of choice's documentation for details.

537 questions
0
votes
1 answer

Find and replace a line in a file

My goal is to search the file line by line until it finds a variable declaration in the format of varName = varValue. Count up the bytes to the beginning of that line, then replace that line with the same varName but a new value. This is a very…
Jacob Birkett
  • 1,927
  • 3
  • 24
  • 49
0
votes
0 answers

Error with IStream.Seek()

I have a very old piece of code to handle Excel files in Delphi 5, which I adapted to work with Delphi 2005, which I used professionally until 2010. Since then, there was no reasonable free version of Delphi. Therefore, it is only now that using…
0
votes
0 answers

What is the right way of replacing a part of line in a file

I have a file GENERIC_MAC with some configurations for my machine, and I want to replace the MAC to a given MAC (hard-coded in this case). Is this the right way? (The code gets me the desired output but I'm not sure about the fs.tellp(); +…
CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
0
votes
0 answers

Kafka Seek to offset is partially working

I am facing issue in kafka consumer for execption handling. My flow: 1) subscribe to kafka consumer 2) poll assign to a buffer map 3) commit (Since the process takes more than session time out duration commiting the consumer before processing) 4)…
sra1
  • 31
  • 2
  • 5
0
votes
1 answer

How to efficiently perform random seeks in a file?

I have a file which is stored on disk and the records are written to the file with a custom record format. A bunch of records will represent a block. When you perform a read in the disk, you can only fetch a block instead of a record. Block =…
user1159517
  • 5,390
  • 8
  • 30
  • 47
0
votes
2 answers

seek() not working properly, although file opened in "r" mode

I have a CSV file of dates and a float (day,month,year,float). here is…
Naji Krayem
  • 83
  • 1
  • 2
  • 9
0
votes
1 answer

python seek() from beginning or from current position?

I'm dealing with a large file (>500GB, few columns but several lines), and I need to get some lines from there. I have this list of start byte and endbytes (measured from the beginning of the file) for the parts that I need, something…
irene
  • 2,085
  • 1
  • 22
  • 36
0
votes
1 answer

Measure the number of seeks

Given a process that intensively read/write file systems, our goal is to measure the number of seeks called in the process? Ideally, we should measure the real seek operations in disk device. Measuring lseek in libc/syscall will be good enough. The…
Richard
  • 14,642
  • 18
  • 56
  • 77
0
votes
1 answer

Arduino Seek wrong position

I have a file with colour values for my led strip. When I try to change some values it just appends them to the end of the file. After some trying and testing I found out that seek jumps to the end of the file instead of the position I tell it to…
0
votes
1 answer

Requesting second video stream in Chrome plays the first video instead

Developed an application in .NET Core to stream video content. Works great with html5 video element, 206 partial packets function (can seek properly). Once I try to stream a new different video, Chrome still plays the first video. I don't have…
Jack
  • 13
  • 4
0
votes
1 answer

Need to use seek(), tell(), next() and readline() function together

In my case, I have two csv file (file1 and file2). To simplify my question, let's say that I want to read elements of file1, 3 by 3 and file2 4 by 4 consecutively. file1.csv (9…
Mas A
  • 207
  • 1
  • 11
0
votes
3 answers

How to optimally move lines with a specific pattern at the top in a huge file using Perl?

I have a huge csv file of nearly 20k rows with below…
0
votes
0 answers

C++ - seekp in a template class

so I have this line of code that I'm using for files: inCreditSystem.seekp((num - 1) * sizeof(client)); // And sometimes I have this code inCreditSystem.seekp((num - 1) * sizeof(ClientData)); where fstream inCreditSystem("credit.dat", ios::in |…
timoleonn
  • 303
  • 1
  • 5
  • 12
0
votes
1 answer

Check after f.seek(mid) if the pointer is at the start of new line or not?

I'm opening a text file and doing a: f.seek(mid) where mid= (0+f.seek(0,2))//2 Now I want to check if the read pointer is at the starting of a new line or not? Based on that I discard f.readline() if pointer is not at the start and read a new line.
kartheek7895
  • 341
  • 1
  • 12
0
votes
1 answer

How to read only a specific part from HTTP Response body

I need to read only the mode segment from the below response body. grant_type=password&username=demouser&password=test123&client_id=500DWCSFS-D3C0-4135-A188-17894BABBCCF&mode=device I used the below function to read the HTTP body and it gives me…
Harsha W
  • 3,162
  • 5
  • 43
  • 77