473,395 Members | 1,905 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,395 software developers and data experts.

Removing blocks of text

Hi.

My application uses a text file as a log. Each log entry has six lines
of text representing data about the application. I need to keep the
file size reasonable so I am trying to write a routine that removes
older entries. My problem is that I could not solve how to remove one
entire block of six lines, once my routine detects it is a older
entry.

That's an example of my log:

--------------------------
Date : 09/09/2004 09:18:30
Module : DataAccess
User : Jim
Sector : RZ
--------------------------

Can anyone help me on this issue?

Thanks,
Robert Scheer
Nov 21 '05 #1
2 934
Robert,

Do you want to open and close the file for a while and rebuild it or do you
want that while the file keeps open for logging.

When it is the last you can forget it, there is a open new, and an append
however not a cut from the middle.

When you can open and close the file, than it is just reading and putting
the 6 rows in a little array when "-----" until "------" occurs. And than
writing that array when the date is false and going on when the date is
true.

I hope this helps?

Cor
"Robert Scheer" <rb******@my-deja.com> schreef in bericht
news:cf**************************@posting.google.c om...
Hi.

My application uses a text file as a log. Each log entry has six lines
of text representing data about the application. I need to keep the
file size reasonable so I am trying to write a routine that removes
older entries. My problem is that I could not solve how to remove one
entire block of six lines, once my routine detects it is a older
entry.

That's an example of my log:

--------------------------
Date : 09/09/2004 09:18:30
Module : DataAccess
User : Jim
Sector : RZ
--------------------------

Can anyone help me on this issue?

Thanks,
Robert Scheer

Nov 21 '05 #2
how about using XML files for logging? They are well structured and hence
should be easier to manipulate anyway you want - especially since .NET has
pretty good support for XML.

Imran.

"Robert Scheer" <rb******@my-deja.com> wrote in message
news:cf**************************@posting.google.c om...
Hi.

My application uses a text file as a log. Each log entry has six lines
of text representing data about the application. I need to keep the
file size reasonable so I am trying to write a routine that removes
older entries. My problem is that I could not solve how to remove one
entire block of six lines, once my routine detects it is a older
entry.

That's an example of my log:

--------------------------
Date : 09/09/2004 09:18:30
Module : DataAccess
User : Jim
Sector : RZ
--------------------------

Can anyone help me on this issue?

Thanks,
Robert Scheer

Nov 21 '05 #3

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

Similar topics

0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
14
by: J.S. | last post by:
In a Windows Form application, which is the better method to concatenate large blocks of code? 1. Reading the text from text files. 2. Adding the text to the VB file itself? Thanks! J.S. ...
102
by: tom fredriksen | last post by:
Hi I was doing a simple test of the speed of a "maths" operation and when I tested it I found that removing the loop that initialises the data array for the operation caused the whole program to...
7
by: Nick Keighley | last post by:
Hi, I took a quick look for a FAQ (apparently this ng doesn't have "a" FAQ). And the resources I've checked are contradictory. I want two blocks of text to appear next to on another. HTML...
17
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...
26
by: brenocon | last post by:
Hi all -- Compared to the Python I know and love, Ruby isn't quite the same. However, it has at least one terrific feature: "blocks". Whereas in Python a "block" is just several lines of...
2
by: flyzone | last post by:
Goodmorning people :) I have just started to learn this language and i have a logical problem. I need to write a program to parse various file of text. Here two sample: --------------- trial...
12
by: Michael7 | last post by:
Hi Everyone, I've been trying to get two blocks of text to be aligned, one left, one right, on the same line. What I'm trying to mimic is what I did with tables here: ...
3
by: Andy B | last post by:
I need to search an xml element for blocks of text. The start of the text block will have a 5 digit number in it and i then need to read until the next 5 digit number. After this, I need to put...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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 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.