Link to home
Start Free TrialLog in
Avatar of johnsodolak
johnsodolak

asked on

Separating a field of un-predictable comma-separated values into individual records and repeating remaining field values in each record for each of the new, separated records?

I have a Filemaker dB table named "Property".  Each record in the table describes an individual owner's property as such:

- Township (Twp)
- Range (Rng)
- Section (Sec)
- Legal Description (Legal)

Twp, Rng and Sec fields all have single, non-comma delimited values per record, but the Legal field contains multiple, comma-separated values, as follows:

Record1      Twp1      Rng1      Sec1      Legal1, Legal2, Legal3
Record2      Twp2      Rng2      Sec2      Legal4, Legal5, Legal6
and so on...

Ultimately I want to have an end-product w/ the values in the Legal field in their own individual record while duplicating the Twp, Rng & Sec fields for the original record into the new records, i.e.

Record1      Twp1      Rng1      Sec1      Legal1
Record1      Twp1      Rng1      Sec1      Legal2
Record1      Twp1      Rng1      Sec1      Legal3
Record1      Twp2      Rng2      Sec2      Legal4
Record1      Twp2      Rng2      Sec2      Legal5
Record1      Twp2      Rng2      Sec2      Legal6

I am unsure of how to do this w/in FM11 solely and directly and I am even willing to export into Excel, manipulate the data and then import into a new table in FM11, if necessary.

This will not be a repetitive task, as this is simply cleanup on a legacy dB that I inherited from a previous employee and therefore accuracy is my primary focus, not repetition.

Thank You in Advance for any and all help you can offer!!!
Avatar of jppinto
jppinto
Flag of Portugal image

Did you tryed Data-Text to Column feature?
Avatar of johnsodolak
johnsodolak

ASKER

No, I have not...can you elaborate?
This will separate the fields in each row into each column.
JPPINTO...I just viewed a quick article on "Data-Text to Column" feature in Excel.  How would I go about moving that "separated" text in each of the new columns back into the original column, create a new row, and duplicate/fill-down the data from the remaining columns in the original row?

Thank You for your response!
Interesting question!

You could do it with a script in FM.

(If the Legal values were in related records then exporting would get you half way there - the same place as the Data-Text to Column)

Going the route you are currently going... maybe this Columnizer software may help:
http://www.aplusfreeware.com/misc/Columnizer/Columnizer.html
Avatar of Will Loving
In order to move this data from your current structure to the structure you describe with multiple records and each "Legal" value you need to do an import from the old structure in a way that isolates each of the comma-separated legal values. Here's how I would do this: Create a calculation field the will determine the N number value in the Legal field:

LegalCalc = GetValue( Substitute( Legal ; "," ; "¶" ) ; 1 )

This calculation will give you the first value in the legal field. It uses the Substitute () function to convert all commas to Carriage returns giving you a return-separated list of all the values in "Legal". The GetValue() function then determines which value get's used, in this case it's value "1". I might take this calculation a little further by adding a Trim() function to it to cleanup and leading or trailing spaces that might be left over after converting the commas, so:

LegalCalc = Trim( GetValue( Substitute( Legal ; "," ; "¶" ) ; 1 ) )

You are now going to do a series of imports from your old table into your new one. The first import is going to simply be all records. You will import the LegalCalc field into the Legal field in the new table. Then, go back, change the 1 to a 2 and do a find in the old table for all records that now have a value in LegalCalc. This will be all records that have a second value in the old Legal field. Import those records into the new table.

Now, go back change the value in the calc from 2 to 3 and perform a find again in the old records which will result in all records that have a third value and import those records. Rinse and Repeat until you have performed as many imports as the maximum number of values that the Legal field might hold. YOu'll know because when you put in a number and perform the Find, no records will be found.

You will now have a set of records for each Property, each one having a unique Legal value.
I was thinking about this and just came up with the same multi export (or multi import) scheme, came back and there's your answer willmcn (that's why you're master level!)

I was going to suggest the MiddleWords Text function which will just grab the right value without having to substitute.

With MiddleWords on the string "one, two, three, four"
MiddleWords ( field; 2; 1) gives "two"
ASKER CERTIFIED SOLUTION
Avatar of Will Loving
Will Loving
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the great responses!  I am going to test all of these out and hopefully be grading tomorrow...
I cannot apologize enough for taking so long to apply these points.  Thank you so much for your response and I still cannot apologize for the tardiness.

The solution was ideal for my situation!