Looking for suggestions on how to do something

  • Thread starter Thread starter Bishop
  • Start date Start date
B

Bishop

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.
 
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.

How about opening 2 file readers, one for each file.

Read each line and concatenate them together - then output to a file
writer?
 
That's a great idea. I'll just add some validation to make sure the item
numbers match before I concatenate them.

Thanks!
 
Reminds me of the old days of doing file updates on tape, Master file (on
tape) in, transaction file (on tape or cards etc) in, new master file out.
Need to compare Prooduct key for hi, low or equal. Mater file product id >
transaction file key implies missing product id for trans. If master file
product id <, advance till >=. When equal, update.
 
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
 
Back
Top