S
Sathyaish
I have a CSV file like so:
"HDR",20060629133932,"9845","9083","0010"
1,"3","000000000690","000007","rsM4hJXR5Ik0O8RWghjtDBlUVAOZq7tO","BAR","0010","","",20.00
2,"3","000000000691","000007","65Xbp5dMcDFflPJnxWCrsJtV1jzcUjgd","BAR","0010","","",20.00
3,"3","000000000692","000007","SEjcf3eDA7hWmwGrNsLWoCWt1Geyh4GN","BAR","0010","","",20.00
4,"3","000000000693","000007","MJMkrp/kRMMGimeZo1uFOJzeDTVeOkFU","BAR","0010","","",20.00
5,"3","000000000694","000007","fDIBFgockQHhN+eVQxEBqqrJfZ78roja","BAR","0010","","",20.00
......and so on...
Each file has about a million records or more. Instead of iterating
through each line and counting line breaks, and ignoring header and
footer records and counting only data records, I thought of writing a
regex pattern for the same. Here's what I've written to count only data
records, i.e rows that start with a number followed by a comma and then
any othe text and ending with a line break.
numRecords = System.Text.RegularExpressions.Regex.Matches(ret,
"(?m)^[0-9]{1, 6}*$",
System.Text.RegularExpressions.RegexOptions.Multiline).Count;
I get a zero match collection count.
"HDR",20060629133932,"9845","9083","0010"
1,"3","000000000690","000007","rsM4hJXR5Ik0O8RWghjtDBlUVAOZq7tO","BAR","0010","","",20.00
2,"3","000000000691","000007","65Xbp5dMcDFflPJnxWCrsJtV1jzcUjgd","BAR","0010","","",20.00
3,"3","000000000692","000007","SEjcf3eDA7hWmwGrNsLWoCWt1Geyh4GN","BAR","0010","","",20.00
4,"3","000000000693","000007","MJMkrp/kRMMGimeZo1uFOJzeDTVeOkFU","BAR","0010","","",20.00
5,"3","000000000694","000007","fDIBFgockQHhN+eVQxEBqqrJfZ78roja","BAR","0010","","",20.00
......and so on...
Each file has about a million records or more. Instead of iterating
through each line and counting line breaks, and ignoring header and
footer records and counting only data records, I thought of writing a
regex pattern for the same. Here's what I've written to count only data
records, i.e rows that start with a number followed by a comma and then
any othe text and ending with a line break.
numRecords = System.Text.RegularExpressions.Regex.Matches(ret,
"(?m)^[0-9]{1, 6}*$",
System.Text.RegularExpressions.RegexOptions.Multiline).Count;
I get a zero match collection count.