"Bishop" <nospam@nospam.comwrote in
news:#QCUwswGHHA.4652@TK2MSFTNGP04.phx.gbl:
Quote:
I have text files that I download daily from one of our vendors. They
are in this format (and they won't change the way they do it)
>
File1:
ProductID, Description, Price, etc....
>
File2:
ProductID, QTY
>
Outside of loading them into a table in the DB and joining the data,
does anyone have any ideas on how to merge the two files so they look
like this:
>
ProductID, Description, Price, QTY
>
The only thing I can think of is to store the ProductID and QTY in an
array or collection and loop through it for each entry.
>
Any suggestions appreciated.
>
>
Create a class to store a Description, Price and Qty. Call this Class
"ProdInfo" Start reading file 1, and populate a hash array with ProdInfo
objects, keyed by ProductID. That means you'll be filling in the
description and price.
Now read file 2, doing much the same thing, using the key to get at the
ProductID and then either work with an existing object in the hash, or
create a new object.
Once you've finished reading file 2, you should then be able simply
right the results you are looking for simply by enumerating the hash.
Personally though, I'd be going down the Database route. This is a five
minute job with SQL server...
Martin