8 Replies Latest reply on Jun 16, 2015 6:52 AM by JuliusBaumann_1

    Export to .csv

    JuliusBaumann_1

      Title

      Export to .csv

      Post

      Hello,

      is it posible to only export the current record do a .csv file ? I know how to export all records to such a file, but in my case, it is important, that the script only exports the current record. So is there any opportunity to get this done ?

      Thanks for your help !

       

      Regards,

      Julius

        • 1. Re: Export to .csv
          MorkAfur

          I didn't immediately see a built-in way to export just the single record to a CSV, but you could create another layout with a single field. Copy your single record CSV to that layout and then export from there.

          - m

          • 2. Re: Export to .csv
            Markus Schneider

            create a new window, isolate the current record, export that - and close the created window. Beside of this, Plugins can write single lines (i.e. Troi, MBS, etc)

            You could also create a virtual list in a utility table

            • 3. Re: Export to .csv
              MorkAfur

              I would say my first idea is the easiest and you don't have to pay $99, or $149 just to do basic file manipulation using a third party library.

              Just create a separate layout, copy the record there into a field, go to that layout, and export it as CSV.

              Done.

              -------

              Note: For myself, rather than buy seemingly expensive FileMaker Plug-ins, I typically would write a REST-based web service that does the "heavy lifting" FMP can't do, then call it from FMP. That might not work in every case, but it's served me well so far. And, all the technology to create web services is free.

              I actually have a web service I use every week that takes a list of CSV created in a script in FMP and it computes the expected value in week 52 using regression. Then, again, from FMP, I call that web service to get the returned data value the web service computed. No plug-ins necessary.

              - m

              • 4. Re: Export to .csv
                JuliusBaumann_1

                Sorry, but I don't know how to do this with a script. Could you help me pls ?

                • 5. Re: Export to .csv
                  MorkAfur

                  Sure, this is super easy once you see it.

                  Problem: You have (for example) two fields, field1 and field2. Given that you have multiple records in this layout, you only want to output the current record to csv.

                  Maybe your CSV file should look like this. Note the header row for first line of the CSV. For this quick example, I called my fields field1 and field2

                  "field1","field2"
                  "value1 for forst field","value1 for second field"

                  To output just this record to CSV, I would first copy the record's values to another layout with just a single record. This layout's purpose, among maybe other things, is just to let you export the single field to CSV.

                  Then, in the script, you would use SET LAYOUT and SET FIELD and possibly New Record Request (if you don't create the single record in the single field layout manually) on the layout you want to use to create the CSV.

                  Then, on that layout with just the one record in it (with the two values from your other layout you copied from), just use a Script Command "Export Field" and set up the options to export as a CSV.

                  Remember too to add the first row for the field names so that if you import the CSV into another system, that system can, optionally, create the field names for you when importing the data.

                  Give it a try.

                  - m

                   

                  • 6. Re: Export to .csv
                    JuliusBaumann_1

                    To output just this record to CSV, I would first copy the record's values to another layout with just a single record. This layout's purpose, among maybe other things, is just to let you export the single field to CSV.

                    Sounds great but I don't find the order to copy the record's values to another layout. I was only ablee to find the order: Export all field values but with that order I have to set a target field and a output file. But if I try this filemaker does not export anything. Neither into the other layout nor into my output file. Could you please help me one more time ?

                    • 7. Re: Export to .csv
                      MorkAfur

                      You use "SET FIELD" to copy a field from one layout to another.

                      http://www.filemaker.com/help/11/fmp/html/scripts_ref1.36.39.html

                      Then when you have the layout with only a single record on it, then you do export all records to CSV. But, since that layout only has the single record, that's all that's exported.

                      I also found when learning FileMaker, that aside from this excellent forum, a book or two was very useful. I especially liked the Missing Manual book for FileMaker. Lots of examples, easy to understand. I still refer to it from time to time.

                      Hope this helps.

                      - m

                      • 8. Re: Export to .csv
                        JuliusBaumann_1

                        It works. Thanks ! :)