5 Replies Latest reply on Apr 25, 2015 7:12 AM by yomango

    Carriage return position for text parsing

    yomango

      Title

      Carriage return position for text parsing

      Post

      i am seeking advise on how to go about parsing 1000 sentences in a single text field into five fields for each sentence (ignore the number 2 ):

        2    
      Fiserv Inc
      www.fiserv.com
      Brookfield, Wisconsin 
      $1 bil. - $5 bil. Revenue Over 10,000 Employees
      Fiserv, Inc., provides integrated information management and electronic commerce systems and services, including transaction processing, electronic bill payment and presentment, business process outsourcing, document distribution services, and software...

      i was hoping to use the carriage return Position function so I can parse the text between carriage returns but FM does not return the right position number. On the instance above, if the calculation is   Position(data::Data;"¶";1;1), the answer is 1; if the calculation is    Position(data::Data;"¶";2;1) the answer is 6 and from then on the answer is always 6.  I used    Position(data::Data;char(13);1;1) and the answers where the same as with the paragraph symbol. I guess I am doing it wrong. I'd appreciate any help

        • 1. Re: Carriage return position for text parsing
          philmodjunk

          Position(data::Data;"¶";1;1) producing a result of 1 would indicate that the very first character in the field is a return. That does not strike me as impossible here.

          Position(data::Data;"¶";2;1)

          Scans for a return starting with the second character. If there is a Return as the 6th character in the field, Position(data::Data;"¶";2;1), Position(data::Data;"¶";3;1), Position(data::Data;"¶";4;1), Position(data::Data;"¶";5;1), and Position(data::Data;"¶";6;1) would all return a value of 6 as they are all finding the position of the same instance of this character. You might try Position(data::Data;"¶";1;2), Position(data::Data;"¶";1;3) to find the position of the 1st and 2nd returns in your text field.

          Keep in mind that other characters can cause text to appear on the second line.

          Also, the GetValue function can be very useful for this kind of parsing. GetValue ( Data::Data ; 2 ) would return the text between the 2nd and third returns in the field.

           

          • 2. Re: Carriage return position for text parsing
            yomango

            Update. I am sorry, i had the Position function formulated wrongly. Now I can pars the first sentence into separated fields with the use of a script. i got stock here, how do I go on down the field text into the second, third, "N" sentences" and how to stop. Since the carriage return follows a pattern of 6, i can formulate the positioning of each text string by adding 6 to the initial position. So the last text string on the initial example I posted "Fiserv, Inc., provides integrated information management and..." would be:

            Let([
                      Start= Position(data::Data;"¶";1;6);
                        end= Position(data::Data;"¶";1;7)];
            Middle(data::Data;start+1;end-start)
            )

            So the next "batch" or sentence as I call it, and for the first text string would be:

            Let([
                      Start= Position(data::Data;"¶";1;8);
                        end= Position(data::Data;"¶";1;9)];
            Middle(data::Data;start+1;end-start)
            )

            until reaching 

            Let([
                      Start= Position(data::Data;"¶";1;12);
                        end= Position(data::Data;"¶";1;13)];
            Middle(data::Data;start+1;end-start)
            )

            ending that batch parsing.

             

            How do I tell the script to go adding 6 to the calculated variable  and how do I tell the script to finish when it reaches the last batch/sentence.?

             

            Thank you

            • 3. Re: Carriage return position for text parsing
              yomango

              Phil, I am reading your advise,and thank you for your time. As I just wrote, I hat truncated the Position function numbers. I do not know how to use the Get Value function but I will look it up. My concern now is how to go down the text field for the next batch and how to stop it when it reaches the last line. Perhaps, to stop it I make a count of carriage returns to compare as I am parsing each batch?

              • 4. Re: Carriage return position for text parsing
                yomango

                Hello, Phil. I got the script doing what I want and stopping at the last batch of information. . Thank you for your interest and time

                • 5. Re: Carriage return position for text parsing
                  yomango

                  Hello, Phil. I just read your message on the Get Value function. that sounds like a great way to parse chunks of information without having to formulate variables the way I did. Thank you