frustrating
Registered User.
- Local time
- Today, 05:12
- Joined
- Oct 18, 2012
- Messages
- 68
All:
I'm building a parser that will evaluate a text document and return data to a database. I'm running into some roadblocks, however, and was wondering if I could get some input or if someone has any ideas on how to make this work. There are two fields I'm really looking at, as an example, we'll say Order and Stuff. The text file will follow this logic:
Order: 1234
Stuff: 1
Stuff: 29
Stuff: 27
Stuff: 14
Order: 5678
Stuff: 83
Stuff: 102
Stuff: 7
Order: 9999
Stuff: 22
Order: 2468
Stuff: 12
Stuff: 72
So what I want to do is take this data and group everything by their respective order numbers, then concatenate the "Stuff" field into one string (semicolon delimited) to insert into the DB. So the output would look something like this:
---
Order: 1234
Stuff: 1;29;27;14
Order: 5678
Stuff: 83,102,7
I would then run a SQL insert or update query to send Order and Stuff to their fields in the DB.
Where I'm getting stuck is when I'm writing my loop to reconcile the Order ID with the Stuff entries. I'd like to evaluate all the data between Order numbers, but I'm having a mental block on a good way of doing this. What is a good way to capture the Order ID and then apply that to respective Stuff IDs?
Any ideas?
I'm building a parser that will evaluate a text document and return data to a database. I'm running into some roadblocks, however, and was wondering if I could get some input or if someone has any ideas on how to make this work. There are two fields I'm really looking at, as an example, we'll say Order and Stuff. The text file will follow this logic:
Order: 1234
Stuff: 1
Stuff: 29
Stuff: 27
Stuff: 14
Order: 5678
Stuff: 83
Stuff: 102
Stuff: 7
Order: 9999
Stuff: 22
Order: 2468
Stuff: 12
Stuff: 72
So what I want to do is take this data and group everything by their respective order numbers, then concatenate the "Stuff" field into one string (semicolon delimited) to insert into the DB. So the output would look something like this:
---
Order: 1234
Stuff: 1;29;27;14
Order: 5678
Stuff: 83,102,7
I would then run a SQL insert or update query to send Order and Stuff to their fields in the DB.
Where I'm getting stuck is when I'm writing my loop to reconcile the Order ID with the Stuff entries. I'd like to evaluate all the data between Order numbers, but I'm having a mental block on a good way of doing this. What is a good way to capture the Order ID and then apply that to respective Stuff IDs?
Any ideas?