Jump to content

empty lines removeal from CSV/flat file


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...