Jump to content
Sign in to follow this  
habitude

Parsing data into new records?

Recommended Posts

Do you know how to parse out text from a field that has a huge amount of text.

Each paragraph begins with a date, where I used a nested substitute calc to insert a "|" before each occurance of a date.

Now the task is to create a routine that would copy each paragraph, and create a new record from those paragraphs into another file.

Can anyone lend a clue please?

Share this post


Link to post
Share on other sites

In another text field, using that substitute function I mentioned earlier, I was able to get that data to appear as a separate record (starting with a date, etc), and I also added a carriage return char so the data looks more normalized.

The final result of this should show the following:

(client_id) (comments)

DOS100022 01/02/96 Bla Bla Bla This is some text

DOS100022 02/15/96 This is some more notes for this client

DOS100022 03/30/96 Some other notes

--

DOS100043 06/05/96 Notes on this other client

and so forth...

All this needs to go from a comments file, into a comments details file.

What am I missing? :-(

Share this post


Link to post
Share on other sites

Are there carriage returns WITHIN each set of parse data? If not and there are carriage returns BETWEEN each paragraph, you wouldnt even have to worry about it starting with a date.

You could just write a simple loop to parse it into separate records. Please report back.

Share this post


Link to post
Share on other sites

I created the followiing calc field to show each "paragraph" as a single item:

Middle( c_Comments_Add_Pipe,

Position( c_Comments_Add_Pipe, "¶", 1 , (g_loop_counter-1) )+1,

Position( c_Comments_Add_Pipe, "¶", 1 , (g_loop_counter) ) -

Position( c_Comments_Add_Pipe, "¶", 1 , (g_loop_counter-1) )-1

)

Now the task is to copy each one of these into the details file, as new record of the "client ID" record (like a line item).

I'm assuming a script that processes each paragraph as a new line item in details is what I need, but I'm not sure how to do it.

Also, when the routine gets to the last paragraph within that record in the main file, the script needs to start the next client id record and strip out the text and add it as a new record of the new client id in the details file.

Does this make any sense? :-!

Share this post


Link to post
Share on other sites

"You could just write a simple loop to parse it into separate records"

How do I write this? If this could be done, and all the data moves over correctly, that would be very righteous.

Share this post


Link to post
Share on other sites

I'd suggest you post a simple file containing the ORIGINAL text (or a representative sample). As John said, the presence of carriage returns is significant, so make sure we get a correct picture there.

Share this post


Link to post
Share on other sites

What does the orig actual raw data format look like?

Share this post


Link to post
Share on other sites

I'm very thankful for the help. I managed to fit all the pieces together (similar, but different from the example) and the script processed all the records the first time (over 40,000) in details! :-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Who Viewed the Topic

    1 member has viewed this topic:
    ron n 
×

Important Information

By using this site, you agree to our Terms of Use.