NickBtheITguy Posted September 13, 2010 Share Posted September 13, 2010 I have several large text files that I am trying to pull certain information together so that it can be imported into another application. I've attached a small excerpt from one of the files to show what I'm trying to work with. The output should be a text file that basically looks like:8: 3310869: 1045710:11: 3299312: 11116114:15:16: 1833517:18: 7952519: 264366I've used pdftotext to dump a PDF to the text file maintaining the format, otherwise everything is so out of order. I know how to open the file, read each line, and write it to another file. What I can't figure out is how to parse each line for the desired information. Some of the lines contain numbers that I don't need and I thought maybe a regular expression would work but I really don't understand using regular expressions.tax1.txt Link to comment Share on other sites More sharing options...
enaiman Posted September 13, 2010 Share Posted September 13, 2010 You might be able to use this pattern on every line to get you the last 2 group of numbers: #include <Array.au3> $str = "16 Advertising ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 16 18335." $tt = StringRegExp($str, "(\d+\h+\d+\.)\z", 1) _ArrayDisplay($tt) It would be up to you to process this further. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Malkey Posted September 14, 2010 Share Posted September 14, 2010 Try this. Local $tt, $i, $sStr $tt = StringRegExp(FileRead("tax1.txt"), "(?:.+~+\h+)(\d+\h*\d*\.*)(?:\v+|\Z)", 3) For $i In $tt $sStr &= StringRegExpReplace($i, "(\d+)(?:\h*)(\d*\.*)", "\1: \2") & @CRLF Next ConsoleWrite(StringStripWS($sStr, 2) & @CRLF) MsgBox(0, "Results", StringStripWS($sStr, 2)) Link to comment Share on other sites More sharing options...
NickBtheITguy Posted September 14, 2010 Author Share Posted September 14, 2010 Thanks! I'm working with both suggestions to see what's going to work for this situation. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now