11 Replies Latest reply on Nov 15, 2013 7:33 AM by philmodjunk

    problems grabbing text and putting to fields

    ryandunne_1

      Title

      problems grabbing text and putting to fields

      Post

           hi all

           basicly i have a text file thats created by an online system that looks like this

           0
           JW062103708GB
           Label Printed
           0
           JW062103711GB
           Label Printed
           0
           JW062103725GB
           Label Printed
           0
           JW062103739GB
           Label Printed
           0
           JW062103742GB
           Label Printed
           0
           JW062103756GB
           Label Printed
           0
           JW062103760GB
           Label Printed
           0
           JW062103773GB
           Label Printed
           0
           JW062103787GB
           Label Printed
           0
           JW062103795GB
           Label Printed
           0
           JW062103800GB
           Label Printed
           0
           JW062103813GB
           Label Printed
           0
           JW062103827GB
           Label Printed
           0
           JW062103835GB
           Label Printed
           0
           JC238932205GB
           Label Printed
           0
           JC238932214GB
           Label Printed
           0
           JC238932228GB
           Label Printed
           0
           JC238932231GB
           Label Printed

            

           and what i need to do is pull the line that starts with j and put it into a field each record going down a list, how do i go about this cheers :)

           p.s. im using scriptmaster to read from file when the file is created and put it into a field but it obviously only sticks it in one record cheers :)

        • 1. Re: problems grabbing text and putting to fields
          philmodjunk

               From what kind of file are you getting this data?

               I don't see why you need to use ScriptMaster for that when you can use import records to do the same thing and that should make it possible to import the text into individual records. If you only want the "JC2...." data, you can import the data into table 1, perform a find to find just those records starting with "J" and then import the resulting found set into your final table.

               You can probably even set up a validation rule on the field into which you import the data that will automatically omit all data that doesn't start with the letter "J" or that omits all values of "0" and "label printed" and import your data in a single import records operation--which can be scripted.

          • 2. Re: problems grabbing text and putting to fields
            ryandunne_1

                 basicly what happens is i export a found set of records and then the couriers online app pick up the export and returns a .txt file formatted like above i then need to apply that just to the found records if i do an import it would apply it to the first lot of records in the database and also it thinks each line is a different record.

                 cheers

                  

            • 3. Re: problems grabbing text and putting to fields
              ryandunne_1

                   i can do it if im only exporting 1 record with this script i made

                   Pause/Resume Script [ Duration (seconds): 6 ]
                   Set Field [ import::tracking number;
                   ReadFileContents( "C:\Users\Postage pc and
                   rippc\Desktop\royal mail\Result.txt" ) ]
                   Set Variable [ $$tracking number; Value:Middle
                   (import::tracking number ; 0 ; 16 ) ]
                   Set Field [ import::tracking number; $$tracking
                   number ]
                   Set Variable [ $$tracking number; Value:Right
                   (import::tracking number;14 ) ]
                   Set Field [ import::tracking number; $$tracking
                   number ]
                   Loop
                   Set Field [ import::label status; "label printed" ]
                   Go to Record/Request/Page
                   [ Next; Exit after last ]
                   End Loop
                   Perform Script [ “delete report” ]

              • 4. Re: problems grabbing text and putting to fields
                philmodjunk

                     If what you show represents a text file, then you can import that text file into a separate table, perform a find to drop out the unwanted values and then use either import records or a looping script to move the data from this table into the table and fields where you need this data.

                • 5. Re: problems grabbing text and putting to fields
                  ryandunne_1

                       ok ive got it so it imports the txt file and then removes the 0 and the label printed bit how do i go about moving the data over? from table to table and keep the found set

                  • 6. Re: problems grabbing text and putting to fields
                    ryandunne_1

                         if i do

                         loop

                               go to record/request/page [first]

                               set field [target table 1::field1;originaltable1::field1]

                               go to record/request/page [next; exit after last]

                         end loop

                          

                         does that look right?

                          

                          

                    • 7. Re: problems grabbing text and putting to fields
                      ryandunne_1

                           ok that doesnt work

                      • 8. Re: problems grabbing text and putting to fields
                        philmodjunk

                             Please describe what you want to happen with this data once it is imported in more detail.

                             Do you need to update existing records or create new records?

                             If it should update existing records, what kind of update? How do you determine which record in your original table should be updated with this newly imported data?

                        • 9. Re: problems grabbing text and putting to fields
                          ryandunne_1

                               thats exactly it i have a database i then find records from the table with ie. SD in a field i then export all those records in the found set i then want to update just that found set with this new information and so on and so forth with each found set

                          • 10. Re: problems grabbing text and putting to fields
                            ryandunne_1

                                 and how i determine what records in that found set is only the order in which the file is is the same order in which the found set lists

                            • 11. Re: problems grabbing text and putting to fields
                              philmodjunk

                                   That's an extremely dangerous way to work with your data. If you can possibly export a unique identifier along with your data, you can match data by that identifier and the accidental omission of a single value or a changed order to the records in either the exported data or the table being updated won't screw up your update.

                                   But what kind of update? Are you just copying the "J" data into a field in the record being updated?

                                   If you are just updating data, you can use import records with the update existing records in found set option. But you'll need to be very careful to always have the correct found set of record with the correct order to them in your target table before you import the records.