Perl Hash Help
Hello,
I have to parse several large text files and enter the results in to a database. Each text file is 65 to 70 thousand pages long. I need a jumpstart getting the text into arrays or hashes and then I think I can take it from there. I used sed to remove garbage from the file, but I am unsure where to go from there. Any help would be greatly appreciated. Here is a sample record from the file: Code:
VENDOR 61125 TOTAL DOLLAR VAR 77,097.60 PAGE 1 2003 08 01 Thanks -Shawn I appologize for the width of the record -- Couldn't think of a better way to post it. |
I would use something like...
Code:
while (<DATA>) { John |
Perl Hash Help
Ok, at this point I am feeling rather stupid and lost.... I have had a few wonderful folks at perlmonks show me how to do this, but it's not sinking in.
Once again, here's the issue at hand... I have a text file (actually 45 of them), each 65,000 pages long. Why? I don't know. Anyway, they are layered as such: Code:
Vendor The code below is what I have: It's not pretty, nor is it right. I need to build the data structure as I loop through. I would think a hash of vendors with a hash of contracts with an array of histories and a hash of footers? Code:
#!/usr/bin/perl |
Hi,
Debugging this for you isn't just a matter of a few minutes. The best thing you can do is get hold of a good Perl tutorial (google) and go down through your code. Get it to work on one file first. It will be fairly easy to put that code into a loop to take care of all files after that. Your basic idea seems ok, but you'll need to think about your data stucture - I guess you will be using hashes of arrays or somesuch. It's not trivial but not impossible either. Sorry I couldn't give more concrete help. John |
John,
Thanks for the help. I have been reading the tutorials on complex data structues and almost have this thing working. I didn't really want someone to write the code. I was trying to find out how to insert an array in to a hash of hashes and how to insert a hash in to a hash of hashes. I was a little frustrated when I made the post (Sorry). The parsing works fine and I actually just went ahead and built all of the sql statements in to the code and inserted the data one step at a time. I just know that it would be much more efficient to try and build the data structure first. As always Thanks for the help.... |
No problem, it wasn't much help.
I find the perl cookbook (link in my previous post) very useful for examples of how to do tricky stuff like hashes of hashes and so on. Good luck! John |
All times are GMT -5. The time now is 12:02 AM. |