473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

inserting into a file

I want to insert a string in a file after a particular line.

I thought of using seek() function but on opening the file in append
mode the seek value is undone.
One crude idea i had was to read the file in a list and insert the
string correspondingly.

Is there any other way to do this?
Please help...

Sai krishna M
--
I love Freedom
Sep 11 '06 #1
1 1674
Sai Krishna M wrote:
I want to insert a string in a file after a particular line.

I thought of using seek() function but on opening the file in append
mode the seek value is undone.
One crude idea i had was to read the file in a list and insert the
string correspondingly.

Is there any other way to do this?
Please help...

Sai krishna M
No "magic" way to insert lines. If file is small, read into
memory, insert line, write to disk. If it is large, read and
write lines to secondary file, insert line, read remaining lines,
delete old file and rename to new file.

-Larry Bates
Sep 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mat | last post by:
Hi, I have a system that uploads images as BLOBs in a database. I also have a function that I use to resize uploaded images before saving as files. I would like to combine these two by resising...
8
by: news | last post by:
I'm building an e-commerce site, where the owner needs to be able to upload a CSV file of product that gets inserted into mySQL. Unfortunately, I think my Web host may have some functions turned...
2
by: tperovic | last post by:
Using SS2K, I'm getting the following error while bulk inserting: Column 'warranty_expiration_date' cannot be modified because it is a computed column. Here is my bulk insert statement: ...
1
by: ajk | last post by:
. Hi, All: I know how to insert files into a Word doc using C#. However, the program I've written to do this runs much too slowly. The "myObj".Application.Selection.InsertFile method executes...
2
by: santuvssantu | last post by:
Hi Friends, I have tried inserting an excel file to a word document.But the following code is inserting the junk information. So can you please help me out? Dim m_WordApp As New...
3
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert...
20
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt...
5
by: pramodkh | last post by:
Hi All I am trying to match a pattern in a file and insert a line. If the pattern matches then insert a line before the matching pattern line. for example, I have the following content in a...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
5
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.