6 Replies Latest reply on Mar 27, 2015 6:46 PM by LandisArnold

    Exporting a csv file

      Title

      Exporting a csv file

      Post

           I need to export customer records. I am exporting this file into another software package. This package requires that the first record contain the names of the fields, such as Name, Phone, address etc. How do I set this up? I have had some ideas but wasn't sure if there is a simple way. This export will need to be done on a monthly basis and will export all customer records that have not been exported before. 

           Thank you

        • 1. Re: Exporting a csv file
          gcatnine

               I used the baseelements plugin http://www.goya.com.au/baseelements/plugin

               using the function BE_WriteTextToFile it is very easy to create a csv file

          • 2. Re: Exporting a csv file
            davidanders

                 Merge Files contain Field Names and end in .mer

                 This post talks about exporting with "Friendly Field Names"

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

                 I have created a "First Record" with the Field Names I want for export, it is a pain.

            • 3. Re: Exporting a csv file

                   Thank you. I think I will try out  Gianandrea Gattinoni's Suggestion first. However, I am a little unclear on the instruction. I have downloaded the plugin and had a look on the site for instruction but at a complete loss.  Could you kindly give me some help or a suggestion of what the script may look like or other actions I need to enforce?

              David, I will try yours if this fails, although your solution may be more complicated having looked at the site and demo file...

              Thank you both

              • 4. Re: Exporting a csv file

                     Just did another search on the net and came across Anvil Dataworks' blog at http://www.anvildataworks.com/?p=151/. They have added this veryuesful and simple technique which I have just tested and it works perfectly. So thank you to him and you for the help...

                      

                "CSV files are by far one of the most common types of delimited text files and thus a popular option for exporting data. The frustrating thing about doing CSV exports from FileMaker is that there is not an option to include field headers, but there is an easy solution. Merge (.MER) files are CSV files with file headers and a different file extension.

                If you are doing a quick export, you can simply rename the file after your export is complete. If you are scripting your export and specifying the path you can tell it to use a CSV extension by using a script variable. For instance if you wanted to export data.csv to the desktop with headers your variable declaration would be:

                “file:” & Get (DesktopPath) & “data.csv”

                "

                • 5. Re: Exporting a csv file
                  gcatnine

                       this for the first two lines of a csv file

                  If[Get ( SystemPlatform ) = 1]

                  Set Variable[$MacOs; Value:True]

                  Set Variable[$EndOfLine; Value:Char ( 13 )  & Char ( 10]

                  Else

                  Set Variable[$MacOs; Value:False]

                  Set Variable[$EndOfLine; Value:Char ( 10 )]

                  End If

                  Set Variable[$output; Value: “field1;field2;field3”& $EndOfLine]   // first csv line

                  Set Variable[$err; Value:BE_WriteTextToFile ( $file; $Output ; False )]  // write of the first csv line

                  Set Variable[$output; Value: Table::Field1 & ”;” & Table::Field2 & ”;” & Table::Field3 & [$EndOfLine]      // second csv line

                  Set Variable[$err; Value:BE_WriteTextToFile ( $file; $Output ; True )             ]// write of the second csv line

                       and so on...

                       $file has to be set with the correct file path (Mac or Windows)

                  • 6. Re: Exporting a csv file
                    LandisArnold

                    Will's merge comment was just the trick.

                    I used to make a record that had the field names in it which was very difficult to use during "finds" followed by exports.

                    New Trick I found following Wills Recomendation of the MER type export (.mer)

                    Export a CSV file quickly with the fields you want.  This will set the file name you need into your folder.

                    Then, reexport the file.  Choose the file name you just created (with your mouse).

                    Then finally, change the format to Merge Format.  This will keep the CSV name but give you a CSV with the field names in it.

                    Thank you Will!  I discovered the rest of this a bit by happen-chance.