|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Looking for suggestions on how to do somethingI 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. "Bishop" <nospam@nospam.com> wrote in How about opening 2 file readers, one for each file.news:#QCUwswGHHA.4652@TK2MSFTNGP04.phx.gbl: > 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. 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! Show quoteHide quote "Spam Catcher" <spamhoneypot@rogers.com> wrote in message news:Xns9893AE3A25E24usenethoneypotrogers@127.0.0.1... > "Bishop" <nospam@nospam.com> wrote in > news:#QCUwswGHHA.4652@TK2MSFTNGP04.phx.gbl: > >> 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? 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. -- Show quoteHide quoteTerry "Bishop" wrote: > 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. > > >
Show quote
Hide quote
"Bishop" <nospam@nospam.com> wrote in Create a class to store a Description, Price and Qty. Call this Classnews:#QCUwswGHHA.4652@TK2MSFTNGP04.phx.gbl: > 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. > > "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
destroying/releasing objects from memory?
Threading Delegate Question Interlocked.Add Not Thread Safe with Longs on a 32bit system Data Relations with DataTable Class vbs to vb.net Error: The transport failed to connect to the server How to Insert field and value into another grid how 2 approximate 0.1 to be 1 Reading int64 from file & converting to DateTime WebBrowser control in vb |
|||||||||||||||||||||||