xillao Posted September 9, 2007 Report Share Posted September 9, 2007 Every week i need to get some information from mutiple text files which is always preceded by "Input rate :" and " Output rate : ". It will be like this Input rate : 1111111 bps Output rate : 2222222 bps And I only need 1111111 and 2222222 and send them to a excel file (or text file) in two columns. One for Input Rate and another for Output Rate. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Cory Posted September 11, 2007 Report Share Posted September 11, 2007 So what's the question? Quote Link to comment Share on other sites More sharing options...
xillao Posted September 11, 2007 Author Report Share Posted September 11, 2007 Sorry, How can i do that with a macro? Thanks, I will be grateful Quote Link to comment Share on other sites More sharing options...
blopib Posted September 11, 2007 Report Share Posted September 11, 2007 xillao: I think you have to be more precise. Quote Link to comment Share on other sites More sharing options...
xillao Posted September 11, 2007 Author Report Share Posted September 11, 2007 I´ll try (sorry, my english is not the best). I have multiple txt files and each file in the middle of other text this kind information Input rate : 1402096 bps (873 pps) Output rate : 4659616 bps (1088 pps) And I only need the data which is preceeded by "Input rate:" and "output rate:". This information for example 1402096 3434344 343434 3434434 etc (estracted from the txt files) send it to a unique file (txt or excel). If it´s possible, one column with the numbers estracted from "Input rate :" field and another column for the numbers estracted from "Output rate :" field. Like this Example of origin data txt file for macro MSERVICE@ADFED> show interfaces fe7-8-8 Input rate : 1402096 bps (873 pps) Output rate : 4659616 bps (1088 pps) New file created after macro Input output 1402096 562634 4659616 742560 1467047 704692 7075471 465964 Thanks, your help is very appreciated Quote Link to comment Share on other sites More sharing options...
xillao Posted September 12, 2007 Author Report Share Posted September 12, 2007 Please help I need your help very badly. Thanks Quote Link to comment Share on other sites More sharing options...
Cory Posted September 12, 2007 Report Share Posted September 12, 2007 First off let me say this is simple and if you just need to get it done and don’t have time to learn I’m available for hire. Also a macro like this would only take a matter of minutes to write so it would be pretty cheap. In this case what I would suck the entire text file into a text variable and then use the Variable Set Integer command and Get Position of Text in a Variable. Then add the number of characters to get to the space in front of the first digit of your number. For Input Rate :” I think the value is 13. Now I would delete that first part of the variable and do another Get Position to find the position of the first space which should be the first space after the number decrement it once and now Copy Part of Text to get your number! Variable Set String %T1% from File: "test.txt" Variable Set Integer %N1% from Position of Text in Variable %T1% Variable Modify Integer: %N1% = %N1% + 12 Variable Modify String: Delete Part of %T1% Variable Set Integer %N1% from Position of Text in Variable %T1% Variable Modify Integer: Dec (%N1%) Variable Modify String: Copy Part of %T1% to %T1% <TVAR2:01:04:c:\test.txt><IVAR2:01:13:1:Input rate :><NMVAR:01:01:1:0000001:2:0000012><TMVAR2:11:01:00:001:N01:><IVAR2:01:13:1: ><NMVAR:09:01:0:0000001:0:0000000><TMVAR2:10:01:01:001:N01:> You would simply add another chunk to the above code to do Output to a different variable. Now just save your variables to a file using Variable Modify String. Look on the second tab for those commands. You might check out my CRLF & TAB macro on my webpage. It can help you build a file. Like I said I'd be happy to write somethign for you too. You could send me some sample files and I can have you up and running in no time. Also I can teach you how I did it so you can tweak it later yourself. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.