I am searching some info about accessing files with stdio functions.
I am able to open a file, read in it with freaf, write in it with
fwrite, modifying its data in "r+" mode ( without truncation nor
appending ), but I have never found how to remove a piece of data
inside a file, like having sequences "aaaa" "xxxx" "bbbb", and needing
to removi second sequence to end with "aaaa" "bbbb", WITHOUT rewriting
the whole file...
Is that possible ? really..
for example, how databases like sqlite do to delete rows so quickly in
big files ? maybe they don't rewrite all the data, do they ?
Somebody told me about "externals data structures" but I didn't found
what he wanted to mean. 3 2242 bl******@gmail.com wrote: I am able to open a file, read in it with freaf, write in it with fwrite, modifying its data in "r+" mode ( without truncation nor appending ), but I have never found how to remove a piece of data inside a file, like having sequences "aaaa" "xxxx" "bbbb", and needing to removi second sequence to end with "aaaa" "bbbb", WITHOUT rewriting the whole file...
Ah, ye antient and extincte art of faqqe-readinge...
<http://c-faq.com/osdep/insdelrec.html>
for example, how databases like sqlite do to delete rows so quickly in big files ? maybe they don't rewrite all the data, do they ?
Nope. Generally, they just mark the row "deleted", and only really
delete the marked rows in one great periodical purging operation, or
they re-use marked rows.
Richard
<bl******@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com... I am searching some info about accessing files with stdio functions.
I am able to open a file, read in it with freaf, write in it with fwrite, modifying its data in "r+" mode ( without truncation nor appending ), but I have never found how to remove a piece of data inside a file, like having sequences "aaaa" "xxxx" "bbbb", and needing to removi second sequence to end with "aaaa" "bbbb", WITHOUT rewriting the whole file...
Is that possible ? really..
No. At some point, the entire file has to be rewritten with the changes.
for example, how databases like sqlite do to delete rows so quickly in big files ? maybe they don't rewrite all the data, do they ?
The answer to how quickly they do it is: linked-lists.
Text editors and spreadsheets usually break the data up into smaller pieces,
such as a "line" or "cell". These smaller pieces are then inserted into a
linked-list of data structures, called "nodes", where one of the elements of
the structure is a "line" or a "cell". Each node also contains other
elements, such as pointers to the other data structures, to be able to
create the linked-list. To delete a "line" or "cell", they delete the node
from the linked list (by changing the pointers in two nodes to "skip" the
deleted node). To delete text within a single "line" or "cell", they use
functions like memcpy or memset to directly manipulate the contents of the
"line" or "cell".
Rod Pemberton
On Tue, 18 Apr 2006 16:13:33 -0400, "Rod Pemberton"
<do*********@sorry.bitbuck.cmm> wrote: <bl******@gmail.com> wrote in message news:11**********************@z34g2000cwc.googleg roups.com... I am searching some info about accessing files with stdio functions.
I am able to open a file, read in it with freaf, write in it with fwrite, modifying its data in "r+" mode ( without truncation nor appending ), but I have never found how to remove a piece of data inside a file, like having sequences "aaaa" "xxxx" "bbbb", and needing to removi second sequence to end with "aaaa" "bbbb", WITHOUT rewriting the whole file...
Is that possible ? really.. No. At some point, the entire file has to be rewritten with the changes.
for example, how databases like sqlite do to delete rows so quickly in big files ? maybe they don't rewrite all the data, do they ?
The answer to how quickly they do it is: linked-lists.
<OT> An even quicker method used by some databases is to simply mark
the row "deleted". The slot may then be reused, or cleaned up at some
later time. </OT> Text editors and spreadsheets usually break the data up into smaller pieces, such as a "line" or "cell". These smaller pieces are then inserted into a linked-list of data structures, called "nodes", where one of the elements of the structure is a "line" or a "cell". Each node also contains other elements, such as pointers to the other data structures, to be able to create the linked-list. To delete a "line" or "cell", they delete the node from the linked list (by changing the pointers in two nodes to "skip" the deleted node). To delete text within a single "line" or "cell", they use functions like memcpy or memset to directly manipulate the contents of the "line" or "cell".
Rod Pemberton
--
Al Balmer
Sun City, AZ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bart_nessux |
last post by:
Hello,
I have some Macbinary files on a PC. I want to recursively read these
files and remove the first 128 bytes of the files if they contain the
macbinary header info. I know how to read...
|
by: Tom |
last post by:
Hi all,
I've searched high and low (google, the FAQ & so on) and I can't seem to
find any way of doing this. What I am trying to do is to edit text files
(eg. ini files) and remove/replace data...
|
by: Anthony |
last post by:
Hi,
Removing files seems to be rather clumsy in C (not C++).
I am trying next piece of code to delete a file (under W32);
int errno;
errno = remove("FSelCancelled");
After exiting the...
|
by: David Pratt |
last post by:
Hi. I'm trying to clean files for packaging on mac using os.path.walk
and want to clean the .DS_Store files that are hidden from view but
could end up in code that I produce.
# Clean mac...
|
by: Niyazi |
last post by:
Hi all,
What is fastest way removing duplicated value from string array using vb.net?
Here is what currently I am doing but the the array contains over 16000
items. And it just do it in 10 or...
|
by: Kilicaslan Fatih |
last post by:
When I push a button to trigger the code:
def runCCCC(self, event):
cmd_out = self.A_com()
if App.runF != "":
os.mkdir('C:\copiedFiles')
for item in App.runF:
App.beCopied = str(item)...
|
by: Eric_Dexter |
last post by:
def simplecsdtoorc(filename):
file = open(filename,"r")
alllines = file.read_until("</CsInstruments>")
pattern1 = re.compile("</")
orcfilename = filename + "orc"
for line in alllines:
if not...
|
by: sebzzz |
last post by:
Hi,
I'm doing a little script with the help of the BeautifulSoup HTML
parser and uTidyLib (HTML Tidy warper for python).
Essentially what it does is fetch all the html files in a given...
|
by: =?Utf-8?B?Sm9lbCBNZXJr?= |
last post by:
I have created a custom class with both value type members and reference type
members. I then have another custom class which inherits from a generic list
of my first class. This custom listneeds...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |