Main Page | Report this Page
Computers Forum Index  »  Computer - Databases - Filemaker  »  Need help with creating a script...
Page 1 of 1    

Need help with creating a script...

Author Message
Steve...
Posted: Wed Oct 07, 2009 12:37 pm
Guest
I hope someone may help me out with this one...
I have a large list of assets. Each asset is in one field and
structured like this:

Light, bulb, 15w, 120v, incandescent, tubular, t6

What I would like to do is create a script that will remove each word
and have it become its own record so that I may restructure the asset
into a standardized form:

Bulb, Light, Incandescent, 15W, 120V, T6

Thank you in advance,
Steve
 
KevinSmith...
Posted: Wed Oct 07, 2009 12:37 pm
Guest
On 7 Oct, 09:37, Steve <sbere... at (no spam) gmail.com> wrote:
Quote:
I hope someone may help me out with this one...
I have a large list of assets. Each asset is in one field and
structured like this:

Light, bulb, 15w, 120v, incandescent, tubular, t6

What I would like to do is create a script that will remove each word
and have it become its own record so that I may restructure the asset
into a standardized form:

Bulb, Light, Incandescent, 15W, 120V, T6

Thank you in advance,
Steve

Hello Steve

I am going to assume that you're:
a) Running FileMaker 10. This script uses features unique to FileMaker
10.
b) Have all the data in FileMaker already, albeit each asset has its
own record with all info for that asset in one field
c) You wish to separate out the asset info into individual fields (not
records as you say above)
d) Working with a copy of the data - not the original data. This is
necessary to prevent data corruption while you are refining your
script.

A quick digression before I get started. If you do not already have
info in FileMaker and it's sitting in a comma delimited text file then
you can use the "Import" function to pull all the info into separate
records and fields.

Now, back to the original scenario. Here's some code off the top of my
head - so please debug it on your system:
*First create some fields. Give them names as follows Characteristic1,
Characteristic2, Characteristic3 etc

show all records
go to record FIRST

//1. Outer loop is to run through all records ie through the whole
list of assets
Loop
SetField [CombinedInformationField; Replace
(CombinedInformationField;",";"¶"] // changes the field where all
info is stored. Sets all commas to be carriage returns "¶" (I hope
that character comes out correctly in the email.) Aim of this is to
set things up so that we can use the wonderful "GetValue()" function
that can pick out each item in turn

//2. Inner Loop is to run through all the characteristics of an
individual asset
Set Variable [$Item,1] // sets a variable called "item" to be
"1" . This will be incremented from 1 to 6 so that we can extract all
the items ie characteristics in the asset
Loop
Set Field By Name ["Characteristic" & $Item; GetValue
(CombinedInformationField;$Item) //This is where it all happens. We're
setting "Characteristic1"..."Characteristic6" fields that you created
at the start. These field names must exactly match what you've set the
field name to be. We're going to set Characteristic1 to be line one,
characteristic2 to be line 2 etc. Remember we've replaced the commas
with carriage returns so that each characteristic sits on a line by
itself.
EXIT LOOP if $Item>6 //that's the number of characteristics that
you have for each asset
END loop

Go to record next, exit after last
End loop

Some further thoughts:
1. If at all possible, go back to the original text file where the
information came from. If you import the text file as a comma
separated file, then it will import it as desired with each item in
it's own field. It will even create the fields for you when you do the
import.
2. Another idea. If all the programming above seems like it's going to
be difficult to get right, try this idea instead. It's a bit fussy,
but less technical. Export all the information out of FileMaker as
"Tab" delimited. Now that you've exported it you can re-import it into
a new file as "comma" delimited. FileMaker should see the commas that
are already there and pop each item into its own field. You may need
to first import the file into Excel first to get it into the right
format ie each item in its own column.

I hope that helps to get you started. Once you've got the script
working you can import the raw data into your development file and run
it for real. After that, change the field names to something more
meaninigful than characteristic1 etc.

Regards
Kevin Smith
 
Dwight Yoakam...
Posted: Wed Oct 07, 2009 9:01 pm
Guest
On 2009-10-07 05:51:32 -0400, KevinSmith
<pleasedonotusethisaddress at (no spam) gmail.com> said:

Quote:
On 7 Oct, 09:37, Steve <sbere... at (no spam) gmail.com> wrote:
I hope someone may help me out with this one...
I have a large list of assets. Each asset is in one field and
structured like this:

Light, bulb, 15w, 120v, incandescent, tubular, t6

What I would like to do is create a script that will remove each word
and have it become its own record so that I may restructure the asset
into a standardized form:

Bulb, Light, Incandescent, 15W, 120V, T6

Thank you in advance,
Steve

Hello Steve

I am going to assume that you're:
a) Running FileMaker 10. This script uses features unique to FileMaker
10.
b) Have all the data in FileMaker already, albeit each asset has its
own record with all info for that asset in one field
c) You wish to separate out the asset info into individual fields (not
records as you say above)
d) Working with a copy of the data - not the original data. This is
necessary to prevent data corruption while you are refining your
script.

A quick digression before I get started. If you do not already have
info in FileMaker and it's sitting in a comma delimited text file then
you can use the "Import" function to pull all the info into separate
records and fields.

Now, back to the original scenario. Here's some code off the top of my
head - so please debug it on your system:
*First create some fields. Give them names as follows Characteristic1,
Characteristic2, Characteristic3 etc

show all records
go to record FIRST

//1. Outer loop is to run through all records ie through the whole
list of assets
Loop
SetField [CombinedInformationField; Replace
(CombinedInformationField;",";"¶"] // changes the field where all
info is stored. Sets all commas to be carriage returns "¶" (I hope
that character comes out correctly in the email.) Aim of this is to
set things up so that we can use the wonderful "GetValue()" function
that can pick out each item in turn

//2. Inner Loop is to run through all the characteristics of an
individual asset
Set Variable [$Item,1] // sets a variable called "item" to be
"1" . This will be incremented from 1 to 6 so that we can extract all
the items ie characteristics in the asset
Loop
Set Field By Name ["Characteristic" & $Item; GetValue
(CombinedInformationField;$Item) //This is where it all happens. We're
setting "Characteristic1"..."Characteristic6" fields that you created
at the start. These field names must exactly match what you've set the
field name to be. We're going to set Characteristic1 to be line one,
characteristic2 to be line 2 etc. Remember we've replaced the commas
with carriage returns so that each characteristic sits on a line by
itself.
EXIT LOOP if $Item>6 //that's the number of characteristics that
you have for each asset
END loop

Go to record next, exit after last
End loop

Some further thoughts:
1. If at all possible, go back to the original text file where the
information came from. If you import the text file as a comma
separated file, then it will import it as desired with each item in
it's own field. It will even create the fields for you when you do the
import.
2. Another idea. If all the programming above seems like it's going to
be difficult to get right, try this idea instead. It's a bit fussy,
but less technical. Export all the information out of FileMaker as
"Tab" delimited. Now that you've exported it you can re-import it into
a new file as "comma" delimited. FileMaker should see the commas that
are already there and pop each item into its own field. You may need
to first import the file into Excel first to get it into the right
format ie each item in its own column.

I hope that helps to get you started. Once you've got the script
working you can import the raw data into your development file and run
it for real. After that, change the field names to something more
meaninigful than characteristic1 etc.

Regards
Kevin Smith

Well, I feel a little silly. I did forget I could import comma/tab
deliminated info. That being said, there are probably 400 or so that
will need to be split and put back together again. I am going to give
the script a shot either way (I love this program...). Thank you for
putting this together for me. I will let you know if the script woks
for me. Either way, you saved me hours of monotonous work. Thank you,
Steve
 
Your Name...
Posted: Thu Oct 08, 2009 12:22 am
Guest
"Steve" <sberebit at (no spam) gmail.com> wrote in message
news:2009100704375516807-sberebit at (no spam) gmailcom...
Quote:
I hope someone may help me out with this one...
I have a large list of assets. Each asset is in one field and
structured like this:

Light, bulb, 15w, 120v, incandescent, tubular, t6

What I would like to do is create a script that will remove each word
and have it become its own record so that I may restructure the asset
into a standardized form:

Bulb, Light, Incandescent, 15W, 120V, T6

Thank you in advance,

I think you mean you want each word in its own Field, not Record. I can't
see why you would want individual Records that say just "Blulb" or "120V".

In this case a simple Import of the comma delimited file should work (as
Kevin Smith said), as long as each asset line is separated by a return
character.

Helpfull Harry Surprised)
 
Steve Berebitsky...
Posted: Thu Oct 29, 2009 5:12 am
Guest
On 2009-10-07 05:51:32 -0400, KevinSmith
<pleasedonotusethisaddress at (no spam) gmail.com> said:

Quote:
On 7 Oct, 09:37, Steve <sbere... at (no spam) gmail.com> wrote:
I hope someone may help me out with this one...
I have a large list of assets. Each asset is in one field and
structured like this:

Light, bulb, 15w, 120v, incandescent, tubular, t6

What I would like to do is create a script that will remove each word
and have it become its own record so that I may restructure the asset
into a standardized form:

Bulb, Light, Incandescent, 15W, 120V, T6

Thank you in advance,
Steve

Hello Steve

I am going to assume that you're:
a) Running FileMaker 10. This script uses features unique to FileMaker
10.
b) Have all the data in FileMaker already, albeit each asset has its
own record with all info for that asset in one field
c) You wish to separate out the asset info into individual fields (not
records as you say above)
d) Working with a copy of the data - not the original data. This is
necessary to prevent data corruption while you are refining your
script.

A quick digression before I get started. If you do not already have
info in FileMaker and it's sitting in a comma delimited text file then
you can use the "Import" function to pull all the info into separate
records and fields.

Now, back to the original scenario. Here's some code off the top of my
head - so please debug it on your system:
*First create some fields. Give them names as follows Characteristic1,
Characteristic2, Characteristic3 etc

show all records
go to record FIRST

//1. Outer loop is to run through all records ie through the whole
list of assets
Loop
SetField [CombinedInformationField; Replace
(CombinedInformationField;",";"¶"] // changes the field where all
info is stored. Sets all commas to be carriage returns "¶" (I hope
that character comes out correctly in the email.) Aim of this is to
set things up so that we can use the wonderful "GetValue()" function
that can pick out each item in turn

//2. Inner Loop is to run through all the characteristics of an
individual asset
Set Variable [$Item,1] // sets a variable called "item" to be
"1" . This will be incremented from 1 to 6 so that we can extract all
the items ie characteristics in the asset
Loop
Set Field By Name ["Characteristic" & $Item; GetValue
(CombinedInformationField;$Item) //This is where it all happens. We're
setting "Characteristic1"..."Characteristic6" fields that you created
at the start. These field names must exactly match what you've set the
field name to be. We're going to set Characteristic1 to be line one,
characteristic2 to be line 2 etc. Remember we've replaced the commas
with carriage returns so that each characteristic sits on a line by
itself.
EXIT LOOP if $Item>6 //that's the number of characteristics that
you have for each asset
END loop

Go to record next, exit after last
End loop

Some further thoughts:
1. If at all possible, go back to the original text file where the
information came from. If you import the text file as a comma
separated file, then it will import it as desired with each item in
it's own field. It will even create the fields for you when you do the
import.
2. Another idea. If all the programming above seems like it's going to
be difficult to get right, try this idea instead. It's a bit fussy,
but less technical. Export all the information out of FileMaker as
"Tab" delimited. Now that you've exported it you can re-import it into
a new file as "comma" delimited. FileMaker should see the commas that
are already there and pop each item into its own field. You may need
to first import the file into Excel first to get it into the right
format ie each item in its own column.

I hope that helps to get you started. Once you've got the script
working you can import the raw data into your development file and run
it for real. After that, change the field names to something more
meaninigful than characteristic1 etc.

Regards
Kevin Smith

Kevin, I appreciate the help with the script. I unfortunatly had to go
with the less tech advanced. Nevertheless, I do appreciate your help.
Thank you,
Steve
 
KevinSmith...
Posted: Fri Oct 30, 2009 2:10 pm
Guest
Quote:
Kevin, I appreciate the help with the script. I unfortunatly had to go
with the less tech advanced. Nevertheless, I do appreciate your help.
Thank you,
Steve

Hi Steve

Thanks for the feedback. In the end, it's the results that matter. I
don't think the script approach is necessarily the quickest. So, well
done for finding a quicker solution.

All the best
Kevin
 
 
Page 1 of 1    
All times are GMT
The time now is Thu Dec 10, 2009 6:06 am