6 Replies Latest reply on Nov 25, 2013 11:49 AM by Vyke

    Position delimited extract

    Vyke

      I need to figure out how to create a position delimited file extract. Any ideas?

        • 1. Re: Position delimited extract
          DamianKelly

          How about something along the lines of 'Export Field Contents' to generate the actual file. Populate the field (global field maybe?) with a script that calcs the file. You will probably want a custom function that pads fields with spaces too.

           

          spacePad(string, length)

          right("lots of spaces here" & string; length)

           

          Thats a bit of a dirty hack as you have effectively hard coded the maximum length, you could recursively add the spaces?

          • 2. Re: Position delimited extract
            beverly

            Does 'extract' mean writing (export) a file, or reading/parsing (import) a file?

             

            Beverly

            • 3. Re: Position delimited extract
              Vyke

              extracting to a flat file to import to another system that requires position delimited files.

              • 4. Re: Position delimited extract
                beverly

                Then you probably need to Export (from FileMaker) to a TEXT file with row(s) of fixed-width (position-delimited) fields. These fields would need to be truncated (if too long) and "padded" if not long enough. Do you have some numbers that need 'precision by decimal' and padded-right with "0"? Do you need to have any dates formatted "just so" (mm/dd/yyyy, yyyy-mm-dd, ???) Do you need a particular delimiter between the fields? Do you need a particular delimiter after each row? Do you need a special character (or two) as "end-of-file"?

                 

                Do you currently have a guide/map of the fields needed and the length of these fields? if so, this would be your guide to the correct format of any kind of data.

                 

                FileMaker can be used to calculate the necessary text and then use Export script step to push the text to a file. You can name the file with any kind of extension. Remember that this is just a text file formatted as needed from your field data.

                 

                ExportFieldContents may also be used, with caveats. See these articles for some ideas on your question:

                http://www.filemakerhacks.com/?p=5616

                http://www.filemakerhacks.com/?p=6045

                 

                Beverly

                • 5. Re: Position delimited extract
                  Vyke

                  Thanks to Brian Dunning's CF list, I found one for numbers that I converted to work with the strings, only issue is, I have to manually add the fields to the calculation and call the function on each field but it will have to work.

                  • 6. Re: Position delimited extract
                    Vyke

                    I figured it out using a CF from Brian Dunning's CF list.