473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Looking for suggestions on how to do something

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.
Dec 8 '06 #1
4 1025
"Bishop" <no****@nospam.comwrote in
news:#Q**************@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?
Dec 8 '06 #2
That's a great idea. I'll just add some validation to make sure the item
numbers match before I concatenate them.

Thanks!
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Bishop" <no****@nospam.comwrote in
news:#Q**************@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?

Dec 8 '06 #3
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.
--
Terry
"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.
Dec 8 '06 #4
"Bishop" <no****@nospam.comwrote in
news:#Q**************@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.

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

Dec 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
Hello, I'm looking to create a PHP script that will automatically generate an index/menu/list (whatever) based on the PDF files that are within a particular directory. I would like the script...
3
by: SpamProof | last post by:
I'm looking for an example of a detailed design that I can follow or get ideas from before programming in vb.net. Currently, I'm using this outline approach that describes my Project, Classes,...
51
by: Matt | last post by:
Hello, I'm a hiring C++ developer employer looking for existing, online C++ aptitude tests. I have not yet extensively researched this yet, but as an example, I thought this test looked...
4
by: N. Graves | last post by:
First... thanks for taking time to read my quest. I have Access database that I have created that once it has been deployed I will not know who has it or who is using it. This is my idea but...
4
by: Gene Hubert | last post by:
I'm looking for a good coding project for the purpose of getting to the point of feeling proficient in VB.NET programming. I've read a few books, written several test apps, and have prior...
2
by: Kenneth McDonald | last post by:
I'm not trying to persuade my company to offer Python as a scripting language for their product, but I am trying to give them examples of things that Python can do easily that cannot be done easily...
6
by: Bob Alston | last post by:
I am looking for others who have built systems to scan documents, index them and then make them accessible from an Access database. My environment is a nonprofit with about 20-25 case workers who...
11
by: matsi.inc | last post by:
I am looking to make something like a delegate that i can use in my projects but am having a hard time getting started. The behavior I am most interested in is how a delegate changes it's Invoke...
1
by: darrel | last post by:
Can anyone recommend a course/class/training event that focuses on OOP concepts in the context of ASP.net? My background: My education is in art/graphic design. Later spending most of my time...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.