Delete X number of lines from files
I am trying to find a way (either through an extension or
some other third-party freeware) to remove a number of lines from
the beginning of my files and replace them with alternate code.
I know that in many cases, a Search and Replace would do the
trick. But in my case, the lines that I want replaced do not
exactly match. For example, I might want to remove the first 15
lines from the beginning of each file in question; however, I might
have three lines of code in the files that each set a variable
value, with that value being different in each file. Thus, as far
as I understand it, the DW Search and Replace would not work for
me.
Even if I have can just find some way to first strip the
lines of code out without replacing it with the new code I want,
that would be fine. Adding in the new code afterwards would not be
an issue.
Any help would be very much appreciated. Thank you very much.
James
On Mon, 7 May 2007 17:14:52 +0000 (UTC), "MUSC Webmaster"
<[email protected]> wrote:
> Gary: Thanks for the suggestion; however it wasn't quite
working for me.
>After your posting, I played around for a bit with
regular expressions and the
>best that I could do was get an expression (^.*\r) that
grabbed all of the
>first line, with the "r" representing a carriage return
as opposed to a line
>feed. If I try to expand on that expression, the search
results come up with
>nothing.
Actually the linfeed is the \n in my suggestion. The ^
designates the
beginning of the string.
Are you on a Mac? I tested it and it worked correctly on my
windows
machine. Come to think of it, I have my line feeds set to
Unix because
that's what my web server uses. You can try replacing the \n
with \r or
\n\r depending on which line feed you're using:
^.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r
or:
^.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\ n
One of the three should work.
Gary
Similar Messages
-
I want to read lines from file, count it and extract numbers from a first line.
i must do un loop?
HI,
i try to explain how to use to LABVIEW TOOLS...
1. USE a for next loop
2. here you must open the file with the VI. read lines from file.
you can choos how many lines you read at same time.
3. the string you can convert into an number.
4. in the loop is the literal counter... this is you line couter....
iun schrieb:
> i must do un loop? -
I added an e-mail account to my iphone using microsoft exchange; all went fine. I then deleted a number of contacts from my iphone that I did not want on my phone. when I went into my e-mail account on my computer the contacts were deleted from there also. Will I be able to retrieve them? If so, how? Thank you.
In the device sync pages select Photos on the top at the right.
Un tick Sync Photos
Apply -
Delete job number & Job name from standard table
Dear Experts,
i want to delete Job Number & job description from table when my job is finished.
thanxhi use the function module..HR_JOB_DELETE
regards,
venkat -
[Solved] Shell script to read unhashed lines from file.
Hello.
I want to write a shell script (it can be bash,sh,ksh,csh or zsh) that will be:
1.Read unhashed lines from file named mirrors.conf.
2.Put them in ~/.profile as PKG_PATH=line catted from mirrors.conf.
Just like as mirrors.conf file for pacman.
Now it can cat lines but how to put them in files as PKG_PATH?
Thanks for answers.
Last edited by SpeedVin (2010-03-01 17:33:20)res wrote:
^ IFS is not necessary here; it won't mess with the white space:
$ echo 'args with formatted spaces ' | while read -r; do echo "$REPLY"; done
args with formatted spaces
It matters for leading/trailing whitespace:
$ echo ' after some ' | while read -r line; do echo "<$line>"; done
<after some>
$ echo ' after some ' | while IFS= read -r line; do echo "<$line>"; done
< after some > -
Assigning a number value to a line from file without array
How do you assign a number value to a line from a file? I want to use the assigned number so that the i can use random number to randomly select a line
Example. i have the lines A,B,C,D,E
A
B
C
D
E
i know that a is line 1 b is line 2 so on so on
(1) A
(2)B
(3)C
(4)D
(5)E
so from here i would use the random number generator so that i could randomly select one of these. I already know how to code for the number generator but how would i make it so that i can access each individual line as a number?ya that's what im using but reguarding the code i dont think it does what im looking for. yes it does provide a random line but wen i run it multiple times it gives me the same line repeatedly. also i need to be able to refer to that line in the future so in the code the String line gets replaced each time
BufferedReader bF = new BufferedReader(new FileReader("someFilePath"));
String line;
int someRandomNumber = 9;
int counter = 0;
while ((line = bF.readLine()) != null){
if (counter == someRandomNumber){
break;
counter++;
System.out.println(line); //line at #someRandomNumber in the file -
Delete some lines from file...
Hi,
I'm using this code
File file = new File(sFile);
if (!file.exists())
file.createNewFile();
fout = new PrintWriter(new OutputStreamWriter(new FileOutputStream(sFile , true)) , true);
PrintWriter fout;
...When file has more then (let's write) 1000 lines, I want to delete last 100 from file.
Can someone help me to do that? Can you posto me a part of code which will done that?
Thanks.If you want to use "standard" (serial) IO, which reads from the beginning of the file, create a line counter, read the file line-by-line, and when the file size limil is reached, close the file - remaining lines will be truncated from the file.
If the file lines are all equal in length, then you can use the RandomAccessFile methods to directly seek to the desired line and delete lines after that point using the class methods - see the seek and setLength methods. -
Dear All,
I have an inbound file to PI.
In the file, there are few lines which are not to be used ... those appear in the top, bottom as well as somewhere in the middle of the file.
I know how to take care of undesired lines from the top, but how to take care of those coming in the middle and the bottom? The number of rows for these undesired extra lines in top, middle and bottom of the file will always be fixed.
Example:-
TOP_LINE1 (Extra line)
TOP_LINE2 (Extra line)
DATA_LINE1
MID_LINE1 (Extra line - HELP required)
MID_LINE2 (Extra line - HELP required)
DATA_LINE1
BOTTOM_LINE1 (Extra line - HELP required)
BOTTOM_LINE2 (Extra line - HELP required)
BOTTOM_LINE3 (Extra line - HELP required)
As I mentioned earlier, the number of rows for these extra lines will always be fixed.
Any suggestions / help will be highly appreciated.
Thanks,
--AbhiThanks Michal for your reply.
But my scenario is a little complex. I will explain here.
1. The file is having data for CONSUMERS and PROVIDERS.
2. After the top_line undesired rows, is the section for the CONSUMERS.
3. After the mid_line undesired rows, is the section for the PROVIDERS.
4. In the file CC, if I specify RECORDSET STRUCTURE - CONSUMERS,,PROVIDERS, - it complains for keyfieldname.
What am I supposed to put in keyfieldname? I don't have any ...
A sample of the inbound file:-
,,,,,"Division",,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,Inventory Report,,,,,,,,,,,,,,,,,,,,,,,,,
Consumer Owner : ABC ,,,,
Consumer :,,,,
Name,Contact,ID,Addr1,Addr2
John White,203 111 2222,1234,,
J D Edwards, 732 020 1121,South West Drive,NJ
Number of Consumers : 201,,,,
Providers :,,,,
ProviderName,Location,LicenseNumber,Contact
ABC,NJ,1001,1800 000 0001
DEF,NY,1005,1 888 000 0001
Number of Providers : 102,,,,
,Summary,,,
I just need the data from the bold rows. Rest of the rows should be discarded. I have desinged the structure like this -
<MT>
<rec>
<Consumer><Name> ... </Consumer>
<Provider><ProviderName>...</Provider>
</rec>
</MT>
Hope the requirement is clear. Kindly help.
Thanks a lot,
--Abhi -
How to restict number of lines from my report output
Hi,
I deveoped a noraml alv report where 26 fields displayed in the report output .But when nuber of lines exdeed 65,000 then we are unable to donload it to spread sheet .so we want to reduce the number of lines based on customer .How to do this in layout is there any facility to restict the number of lines ??
Please help meHi I am not sure but you can try like devide table entries in multiple internal tables.
Create saperate ALV Report and give customized button(Next and Back) to each report will have interlink to this reports. -
Extract certain bytes number of bytes from file
If I wanted to extract a certain number of bytes from a DataInputStream what would the best way to stop the copy after a certain number of bytes?
would the use of the written field of the stream do?
has anyone got any suggestions?
Cheers :)is this a trick question or would this do what you want?
Here's the javadoc from the "read" method of the DataInputStream Class:
int read(byte[] b, int off, int len)
Reads up to len bytes of data from the from the contained input stream into an array of bytes. -
Hi Team,
we have a file server on windows server 2008 R2, I have copied some data from one server to another server using robocopy . I have checked access permission it seems okay no issues with access permission. but when i am trying to delete these folder i am
getting below error message
Error message:-
The source file name are larger than is supported by the file system.try moving to a location which has a shorter path name or try renaming to shortcut names before attempting this operations
Regards,
Triyambak
Regards, TriyambakI have tried everything , but nothing help , getting same error
could any one help me regarding this.
Regards, Triyambak
I have not looked at the other thread mentioned, but usually when this ends up happening, There are several ways to go about it. One is to map a drive to the UNC path deeper into the folder structure.
So instead of C:\long\path\that\we\dont\want\files\in
You map a drive.. lets say M:\ to \\computer\c$\long\path\that\we\dont\want
Now, when you open Explorer to M:\ you've elimintated the length of the path down to M:\files\in which is completely usable.
The other way, is to shorten the names of everything. For example...
Folder structure like this:
Root
-----Folder1
-----Folder2
--------------Folder2A
-----Folder3
--------------Folder3A
Rename all the folders to shorten up the path. Rename Folder1 to '1' Rename Folder2 to '2', Rename folder3 to '3. Then try to delete. If it's still too long, go one folder deeper. Rename Folder2A to '1' and
Rename Folder3A to '1' and so on. Basically keep renaming everything to a single digit character and eventually you'll shrink the path down to where you can shift-delete everything remaining.
Hope that helps.
Brian / ChevyNovaLN -
Delete large number of accounts from GL master
Hello All:
Doing a large amount of Account deletion. There is no DI support on the topic, so I was trying to use UI on form 750.
I tried both method of either using the find button and then delete or search through matrix. -> click on the row to bring up the accounts and then activatemanul
I am having problem for some reason, that after certain number of record found. The delete manual 5910 no longer works. It doesn't sent out exception nor does it do anything. If you try to manually do it it will still work. But I suppose just the progarm runs so fast that it can not catch up?
I don't know if anyone has a better solution because I have tried several ways with no improvement. It sill locate the record fine, but wouldn't delete the accounts.It just go to the next record without doing anything!
for (int i = 0; i < Global.orecord.RecordCount; i++)
Global.formatcode = Global.orecord.Fields.Item("formatcode").Value.ToString();
Global.omatrix = (SAPbouiCOM.Matrix)(Global.oform.Items.Item("3").Specific);
for (int i2 = lastnum; i2 <= Global.omatrix.RowCount; i2++)
Global.oedit = (SAPbouiCOM.EditText)(Global.omatrix.Columns.Item("1").Cells.Item(lastnum + 1).Specific);
formatcode1 = Global.oedit.Value.ToString();
if (formatcode1.IndexOf(" - ") != -1)
formatcode1 = formatcode1.Substring(0, formatcode1.IndexOf(" - "));
formatcode1 = formatcode1.Replace("-", "").ToString();
if (formatcode1.Length == 21)
try
if (formatcode1 == Global.formatcode)
Global.omatrix.Columns.Item("1").Cells.Item(lastnum + 1).Click(SAPbouiCOM.BoCellClickType.ct_Regular, 0);
Global.oapplication.ActivateMenuItem("5910");
break;
else
if (System.Convert.ToInt64(Global.formatcode.Substring(0, 13)) <= System.Convert.ToInt64(formatcode1.Substring(0, 13)))
break;
catch { }
lastnum = i2;Thanks, rkaufmann87, I've tried that many times thinking I can sneak up on it (funny when we're to the point to try ANYTHING)----AB not cooperating on that one, either. The group will delete, but the names/cards are still on the main list and won't delete from the main Address Book. If you "select all" it goes back to the Address Book main list, not the group which is wanting to be deleted.
-
Hi. I use buffered reader to read from a file. The file contains a line of strings (04/21/2005 some text bla bla here). Each line ends with a \n, to define that its the end of the line. How can i print this out, so each line is printed on a new line? Suggestions?
String filename = "someFile.txt";
BufferedReader infile = new BufferedReader(new FileReader(filename));
String read;
while ((read = infile.readLine()) != null)
//print each line, but how?
infile.close();I was wondering if the \n defines that its "end of
line" so that all strings between the \n is
understood as one line.Yes. It may also be \r\n, depending on the platform. It's one of the System properties. line.delimiter, I think.
Allso, when i print with
System.out.println(infile); only
java.io.BufferedReader@691177 is printed. Do I have
to parse it in any way?No. You normally can't "print" an object. All you'll do is print out the result of the object's toString() method, which usually returns the class name and the object's hash code.
And you should keep in mind that a File object is only a representation of the file's name. It has no access to the file's contents. -
Fire an event automatically after reading line from file
Hi all
I am writing a programe in which i need to fire an event automatically after reading each line (i.e. on every EOL) from the file.
Thanks
jonjonhill wrote:
..I am writing a programe in which i need to fire an event automatically after reading each line (i.e. on every EOL) from the file.Thanks for sharing that with us. Let us know how it goes. If you have any questions, feel free to ask them.
BTW - sounds like a very weird requirement. -
Open email, search for text, delete X number of lines and/or paragraphs?
How would one go about this?
I have existing code that uses the objActionsMenu.Execute to "resend" the message, essentially creating a new email that I can edit.
I would like to be able to:
1) Search for a keyword
2) Move to the end of the line and/or paragraph
3) Delete the contents
The reason is that I often receive important emails with 50+ lines of names and email addresses on the "To:" or "CC:" lines. I want to quickly and easily remove these so I can get to the important part of the email.
Am I going about it the right way? If so, how would I accomplish this? Thanks.
How would one go about this?
I have existing code that uses the objActionsMenu.Execute to "resend" the message, essentially creating a new email that I can edit.
I would like to be able to:
1) Search for a keyword
2) Move to the end of the line and/or paragraph
3) Delete the contents
The reason is that I often receive important emails with 50+ lines of names and email addresses on the "To:" or "CC:" lines. I want to quickly and easily remove these so I can get to the important part of the email.
Am I going about it the right way? If so, how would I accomplish this? Thanks.
I think you maybe in the wrong forums :). This is for Excel and not Outlook. This is a general VBA question though. The easiest way to do this is the following:
-Assign the content of the email body to a string variable.
-Use the split function to split at the keyword, and keep the string portion BEFORE the keyword.
-Assign the split string back to the email body so something like this:
Public Sub ReplyWithAttachments() ' Ensure reference to Word Object model is set
Dim rpl As Outlook.MailItem
Dim itm As Object
Set itm = GetCurrentItem()
If Not itm Is Nothing Then
Set rpl = itm.Reply
rpl.BodyFormat = olFormatHTML
rpl.display
End If
Dim objDoc As Word.Document
Set objDoc = rpl.GetInspector.WordEditor
Dim txt As String
txt = objDoc.Windows(1).Document.Range.text
txt = Split(txt, "To")(0) '
objDoc.Windows(1).Document.Range.text = txt
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
GetCurrentItem.UnRead = False
Set objApp = Nothing
End Function
Maybe you are looking for
-
PLEASE HELP -- iTunes Match - multiple problems, desktop and iOS
I've been going round and around with this issue for the past couple days (yes, I've been dedicating that much time to it) and finally went to the Genius Bar today to get help and even they were stumped. Hoping someone here can shed some light on th
-
Applying RPM while running patch
Hi we are using oracle 12.1.1 on OEL 5.4 I want to enable telnet service i need to aaply rpm but other side patch is running and it is taking time. my question here is it possible to apply rpm while running NLS patch activity? Thanks With Regards OH
-
I have to allow few Andriod users to access my firm , have ASA 5510 with 10 ssl license . Now i came to know that i need AnyConnect for Mobile license. Can any one of you let me know what licence is required
-
Why Division is not Mandatory in CRM
Hi , I am new to CRM...I am working in SD. Just want to know why division is not mandatory in CRM like in SD. Thanks for your time RamaChandra
-
How can I get a video off of adobe premier elements 7 into Windows Movie Maker?