5 Replies Latest reply on Mar 23, 2015 10:38 AM by dash

    Export txt file with headers?



      Export txt file with headers?


           I really need headers in the txt file I am trying to export out FM Pro 12. I set it as a Tab-Seperated file with .txt extension.. anyone know how to include the headers with this type of export?

        • 1. Re: Export txt file with headers?

               Take a look at the format of a merge file export. it includes the field names, but the format may not be one that will work for you.

               Otherwise, you might have to generate a dummy record with the needed fields names stored as data in the fields and positioned as the first record in the found set of data to be exported--that creates a record you don't want to keep in your database after export and one that may have a number of datatype issues if you are exporting date, time or timestamp data--so this may not be possible for your particular export specifications.

          • 2. Re: Export txt file with headers?

                 Scavenged from the internets.

                 FMP ver 8, the Excel options for exporting have a "use field names as column names in first row" checkbox.

                 An alternative would be simply to add a new (temporary) first record in which the field contents match the field names. You could script this to revert back following the export.  This would work for any export format EXCEPT Merge - there would be duplicate headers.

                 Or you can export in the format known as "Merge", which always contains the field names as a header row. "Merge" files are just comma-separated value format, so if Excel for Windows is not cognizant of what the heck a ".mer" file is, change the extension to ".csv" or even just ".txt" and it should work fine.

            • 3. Re: Export txt file with headers?

                   Take a look at this example using xml styling to export Tab delimited files with headers


              • 4. Re: Export txt file with headers?

                     Thanks Marc, worked perfectly :) Thanks to Phil and David for responding as well but those options don't work for me in this particular instance.

                • 5. Re: Export txt file with headers?

                  This is an old thread, but I found it helpful.  Here is a modified XSLT file that will use comma separated variables and enclose the values in double quotes.  Also had to change the line feed (#10) to a carriage return (#13).  That may have been a Mac vs Windows issue or the software that I was generating the file to import into.  Also added a static header section that was required by the software I imported the data into.

                  Modified file below


                  <?xml version='1.0' encoding='utf-8'?>
                  <xsl:stylesheet xmlns:fmp="http://www.filemaker.com/fmpxmlresult"
                  exclude-result-prefixes="fmp" version="1.0"
                  <xsl:output method="text"/>
                      <xsl:template match="/">
                          <xsl:comment>Insert static one time
                              data for import</xsl:comment>
                          <xsl:comment>This is the header row for records</xsl:comment>
                          <xsl:for-each select="fmp:FMPXMLRESULT/fmp:METADATA">
                              <xsl:for-each select="fmp:FIELD">
                                      <xsl:text>&#34;</xsl:text><xsl:value-of select="@NAME"/><xsl:text>&#34;</xsl:text>
                                      <xsl:if test="position()!=last()"><xsl:text>&#44;</xsl:text></xsl:if>
                          <xsl:comment>This is the record set</xsl:comment>
                          <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
                              <xsl:for-each select="fmp:COL/fmp:DATA">
                                      <xsl:text>&#34;</xsl:text><xsl:value-of select="."/><xsl:text>&#34;</xsl:text>
                                      <xsl:if test="position()!=last()"><xsl:text>&#44;</xsl:text></xsl:if>
                              <xsl:if test="position()!=last()"><xsl:text>&#13;</xsl:text></xsl:if>