Hey all.
It's been, well.. damn near forever since I've had to do anything of this sort and I can't think/find an easy way to do it at the moment.
What I need is either a script/macro/software that is free or has a fully functional trial that will do the following things (this is on a Windows xp system):
1)Search through a directory of files (text files in this case)
2)Find a particular variable I define (in this case all data that occurs between "[" and "]".
3)Output the results to a file (text, spreadsheet, doesn't matter).
Optionally if it would only return unique results that would be ideal, but not a requirement.
EDIT:
If this can be done with some sort of macro/vbscript within MS office that's fine too as I have access to those (2003 and 2007).
Posts
Either way, you're basically going to open it and read it character-by-character - when you see "[" you start dumping to a file, when you see "]" you stop. Assuming there's no nesting, it's that simple. If you start getting to the point of multiple [[]]][]][][]][[[][][[][][]]] sets like that, you're into more complex shit and I have to ask which part is most important.
Can trade TF2 items or whatever else you're interested in. PM me.
Okay, but are they nested? If they're not nested ( [ data1 [ data2 ] data3 ] ) or staggered ( [ [ [ ] [ ] ] [ ] ] ) then you can just parse character-by-character like I outlined in the first post.
Can trade TF2 items or whatever else you're interested in. PM me.
PSN: TheScrublet
Stupidly easy then, you can write this in VBScript. Free, included with XP, and to open an IDE you just type notepad :P
Can trade TF2 items or whatever else you're interested in. PM me.
Python is also free, but not included with Windows.
For example, I created a file named test.txt that contains the following:
The above grep statement gives me the following output when given test.txt as the input file:
If you have many files in one folder, you can use wildcards to return results from all files at once (e.g. *.log or *.* instead of filename.txt). The version of grep I used is 2.5.1 for Windows. It is free, open source, and available for download here.
Edit: Oh, missed the uniqueness requirement. You can do that by also downloading GNU CoreUtils for Windows and piping the grep output to uniq:
Here's why that does with my test file:
If you need the output in a file, just redirect to a file using the standard file redirection operator:
Replace the directory path on line 6 (where it says os.walk() ) with the directory your logs live in.
You'll need to install Python. This was done in 2.5, but should work in any version.
save it as a .py file. You'll need to make sure the indentation is as appears here.
If someone knows a more elegant Pythonic way that'd be neat. I only started learning Python a few months ago, so I'm still mostly writting C++ in Python.
Can trade TF2 items or whatever else you're interested in. PM me.
To rip off Tycho:
Sometimes, the old magic is best.