Jump to content

empty lines removeal from CSV/flat file


parrot
 Share

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..

Edited by parrot
  • Like 1
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

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
 Share

×
×
  • Create New...