habitude Posted July 20, 2007 Posted July 20, 2007 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?
habitude Posted July 20, 2007 Author Posted July 20, 2007 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? :-(
mr_vodka Posted July 20, 2007 Posted July 20, 2007 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.
habitude Posted July 20, 2007 Author Posted July 20, 2007 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? :-!
habitude Posted July 20, 2007 Author Posted July 20, 2007 "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.
comment Posted July 20, 2007 Posted July 20, 2007 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.
mr_vodka Posted July 20, 2007 Posted July 20, 2007 What does the orig actual raw data format look like?
habitude Posted July 20, 2007 Author Posted July 20, 2007 (edited) Here ya go. I hope this works And by the way, thank you kindly! Comments_Copy.zip Edited July 20, 2007 by Guest
comment Posted July 20, 2007 Posted July 20, 2007 That's a good start you've made there. See if this helps you to finish it. Comments_Folder.zip
habitude Posted July 21, 2007 Author Posted July 21, 2007 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! :-)
Recommended Posts
This topic is 6337 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now