开发者

counting number of lines in a text/csv file using OSB

I have a CSV file, I need to count the total number of lines in that file. This I have to use in OSB. My requirement is I have to count total no of lines in the $body file (CSV/flat file) and subtract header and footer lines from it, using either XSLT/开发者_StackOverflow中文版Xquery.

EX:

header,1, @total_no_of_detal@
detail,1
detail,2
detail,3
"
"
detail,n

footer, 1

If suppose i have 10 detail lines, and I am getting body of the file as shown above,

then in the final file, I have to change the body of the file as:

header,1, 10
detail,1
detail,2
detail,3
"
"
detail,n

footer, 1

Please advice how to do this in OSB.


Assuming the flat file is just red into the $body variable, here is how you can count the lines:

fn:count(fn:tokenize($body/text(), '(\r\n?|\n\r?)'))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜