Jump to content

empty lines removeal from CSV/flat file


parrot

Recommended Posts

Hi,I have a CSV output file, where in it has empty lines at the end of the file, I want to remove these empty lines, Can some one pls help on this, as how to remove these empty lines by using Xquery/XSLT.sample file:20110706,GGG,LMM,Q,POT,O20110708,AAA,OPP,P,MAT20110715,BBB,TTT,O,TIN// empty linesThanks..

Link to comment
Share on other sites

I am not sure why you want to process and manipulate plain text files like CSV files with tools like XQuery or XSLT which are geared towards processing XML.However XSLT 2.0 has http://www.w3.org/TR/xslt20/#unparsed-text so it can process and load text files. With that approach you could do e.g.

<xsl:output method="text"/><xsl:param name="input-csv" select="'test.csv'"/><xsl:template name="main">  <xsl:value-of select="tokenize(unparsed-text($input-csv), '\n')[normalize-space()]" separator=""/></xsl:template>

which would pull in the text, break it up into lines and throw away empty lines before outputting the lines again.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...