You are not logged in.

#1 2005-10-21 21:32:59

leeghoofd
Member
From: the Netherlands
Registered: 2005-04-28
Posts: 61

Reading a part of a file

Hello, do you know if this is possible (doesn't matter what language..):

If I have a big file which is much larger that my memory + swap space, say 20gb. Is it possible to say something like read the part from  the 1132312 byte to the 2132312 byte into memory. And than in memory having the option to do normal things like it was a normal file like reading it from the begin to then end byte by byte. Also is it possible to say something like replace the part from the 12312312 byte to the 22312312 byte with this that I have in memory?

I only know of things like read write and append but as far as I know this is only possible with small files.

Thanks in advance,
David

Offline

#2 2005-10-21 23:51:00

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Reading a part of a file

leeghoofd wrote:

I only know of things like read write and append but as far as I know this is only possible with small files.

In C and most lower level languages, opening a file requires something in the area of 2-3 pointers.  That's it.  The file handle and what's called a "file pointer" which contains the location.  You can use open(), seek(), and read() to get where you want are read the amount you want.

Offline

#3 2005-10-22 11:32:27

kleptophobiac
Member
From: Sunnyvale, CA
Registered: 2004-04-25
Posts: 488

Re: Reading a part of a file

What language are you using?

Offline

#4 2005-10-25 02:15:14

renners1
Member
From: Thailand
Registered: 2004-11-03
Posts: 71

Re: Reading a part of a file

Many languages have a file pointer. You can move the pointer to anywhere in the file and read your required amount of data from that point onwards. The command to move the pointer is often MOVE or SEEK... check out your lanuage docs.


Microsoft stole my computer, Linux gave it back.

Offline

#5 2005-11-02 08:25:39

leeghoofd
Member
From: the Netherlands
Registered: 2005-04-28
Posts: 61

Re: Reading a part of a file

Hello,

Thanks for your replys, and sorry for my very late reply, I forgot to it smile

I use ruby, I have found what you mean, it is IO.pos= to move to a position in the file. I haven't tested with a file bigger than the mem+swap but I think it works.

Thanks,
David

Offline

Board footer

Powered by FluxBB