-
December 26th, 2008, 05:14 PM
#1
[RESOLVED] Editing ASCII files
Good day to all.
I'm accessing an ASCII file, a large one, and my application needs to insert a character in a certain position to update data. The question is related to physical memory handling in moving the part of file that follows the newly inserted character... It is the only way to create a new file in which copy the part that precedes the inserted new char, then append the char and finally paste the subsequent original second part of the file? Because of the size of the file, this is not very fast...
If it is the only way, does anybody have some hint on how to perform it faster?
Thanks in advances, and nice holidays to all!
- Buzzyous -
-
December 26th, 2008, 05:19 PM
#2
Re: Editing ASCII files
What do you mean byt "LARGE"???
A quick test on my machine did this for a 100MB vector in under 100mS....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
December 26th, 2008, 07:04 PM
#3
Re: Editing ASCII files
- Buzzyous -
-
December 26th, 2008, 07:13 PM
#4
Re: Editing ASCII files
Originally Posted by Buzzyous
What about 12 GB?
Isn't this something you should be trying yourself before assuming it's slow? If it is slow, then show us the code you're using to do this operation.
Regards,
Paul McKenzie
-
December 26th, 2008, 07:19 PM
#5
Re: Editing ASCII files
I cannot think now of a classical IO approach that will make this acceptably fast (from an end user's point of view).
Have you thought of using MMF's? (Memory Mapped Files). They would make altering such a large file relatively easy, considering the alternative.
Here's an article to get you started: http://msdn.microsoft.com/en-us/library/ms810613.aspx
You can post here if you have any more questions about this technique.
-
December 26th, 2008, 07:31 PM
#6
Re: Editing ASCII files
Originally Posted by marceln
As a 64 bit application on a machine with ALOT of memory, that might be feasible.....Unfortunately most "affordable" machines will only support 12GB total RAM....
But to be honest, I have NEVER seen a 12GB text file.
If that was printed as a set of books, it would take over 120 meters of shelf space...More than a football (American or European) field is long.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
December 26th, 2008, 07:45 PM
#7
Re: Editing ASCII files
It is not text file, just ASCII file. I can access data as characters, but data is not necessarily to be interpreted in that form. They can be anything, like imagines, audio, video, etc.
The solution in the link seems nice, but in any case I found an error in the program; it now works in the times presented by CPUWizard, that are more acceptable than before.
Thanks to all for the very fructuous help, it really fastened things up for me. As usual, Codeguru is OK.
Bye to all, until next time!
- Buzzyous -
-
December 26th, 2008, 07:49 PM
#8
Re: Editing ASCII files
You managed to do this:
create a new file in which copy the part that precedes the inserted new char, then append the char and finally paste the subsequent original second part of the file
with a 12 gb file in under 100 ms?
-
December 26th, 2008, 07:57 PM
#9
Re: Editing ASCII files
Originally Posted by Buzzyous
I
Bye to all, until next time!
Dont forget to mark threads as resolved, and to rate those who helped....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
December 26th, 2008, 09:52 PM
#10
Re: Editing ASCII files
Originally Posted by marceln
You managed to do this:
with a 12 gb file in under 100 ms?
Ahaha! No of course not... in 100 ms for 100Mb of course!
- Buzzyous -
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|