Jump to content

No header when exporting to CSV file


This topic is 2806 days old. Please don't post here. Open a new topic instead.

Recommended Posts

On 11/8/2016 at 9:26 AM, BruceR said:

1. Which is it? A  tab delimited file is not a CSV (comma delimited).

2. I f CSV is you want, choose the merge option.

Sorry, Bruce. You are right. I want TAB delimited.

On 11/8/2016 at 11:04 AM, comment said:

Thanks, Comment. Unfortunately these solutions are too complicated for me. Fenton's example (Export_Tab_wHeader_xml.zip) works fine. My problem is how to merge Fonton's .xls with my existing ditto:

Fenton:

<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet xmlns:fmp="http://www.filemaker.com/fmpxmlresult"
exclude-result-prefixes="fmp" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
	<xsl:template match="/">
		<xsl:for-each select="fmp:FMPXMLRESULT/fmp:METADATA">
			<xsl:for-each select="fmp:FIELD">
					<xsl:value-of select="@NAME"/>
					<xsl:if test="position()!=last()"><xsl:text>&#09;</xsl:text></xsl:if>
			</xsl:for-each>
		<xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
			<xsl:for-each select="fmp:COL/fmp:DATA">
					<xsl:value-of select="."/>
					<xsl:if test="position()!=last()"><xsl:text>&#09;</xsl:text></xsl:if>
			</xsl:for-each>
			<xsl:if test="position()!=last()"><xsl:text>&#10;</xsl:text></xsl:if>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>

Kurt:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fmp="http://www.filemaker.com/fmpxmlresult">

<xsl:output method="text" encoding="ISO-8859-1"/>

<xsl:variable name="CRLF">
<xsl:text>&#x000D;&#x000A;</xsl:text>
</xsl:variable>

<xsl:variable name="delimiter">
	<xsl:text>	</xsl:text>
</xsl:variable>

<xsl:template match="/">
    <xsl:text>v_products_model	v_products_name_1	v_products_description_1	v_products_page_title_1	v_products_meta_keywords_1	v_products_meta_description_1	v_products_short_description_1	v_products_image	v_products_price_per	v_products_ean	v_products_price	v_products_quantity	v_products_weight	v_categories_name_1_1	v_categories_name_2_1	v_categories_name_3_1	v_manufacturers_name	v_tax_class_title	v_status	EOREOR&#x000D;&#x000A;</xsl:text>

<xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
	<xsl:for-each select="fmp:COL">
		<xsl:value-of select="fmp:DATA"/>
		<xsl:choose>
			<xsl:when test="position()=last()">
				<xsl:value-of select="$CRLF"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$delimiter"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:for-each>
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

 

Link to comment
Share on other sites

2 hours ago, Kurt Hansen said:

My problem is how to merge Fonton's .xls with my existing ditto:

That's not a good description of a problem. What exactly is wrong with your attempt? Assuming you want to hard-code the column names in the header, instead of copying the field names from your database, I see no reason why this would not work - provided you export the fields in the same order as required by the header.

Link to comment
Share on other sites

This topic is 2806 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.