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?
Take a look at this example using xml styling to export Tab delimited files 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.
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.
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.
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:comment>Insert static one time
data for import</xsl:comment>
<xsl:comment>This is the header row for records</xsl:comment>
<xsl:comment>This is the record set</xsl:comment>
<xsl:if test="position()!=last()"><xsl:text> </xsl:text></xsl:if>
Retrieving data ...