Page 1 of 1

Count the number of times a line is in a file

Posted: Fri May 23, 2008 4:51 am
by gotcher
I want to look at the all of the characters up to the first comma (it may very in size) in a line and see how many times that line shows up in a file and then append that number to the end of the line.

The example file would look like:
1234567890,11111,5/22/2008,6/22/2008,01,400.00
1234567890,11111,5/22/2008,6/22/2008,02,100.00
1234567890,11111,5/22/2008,6/22/2008,03,120.00
0987654321,22222,5/22/2008,6/1/2008,01,123.65

then the out put would be:
1234567890,11111,5/22/2008,6/22/2008,01,400.00,3
1234567890,11111,5/22/2008,6/22/2008,02,100.00,3
1234567890,11111,5/22/2008,6/22/2008,03,120.00,3
0987654321,22222,5/22/2008,6/1/2008,01,123.65,1

Any help is greatly appreciated.

Re: Count the number of times a line is in a file

Posted: Thu May 29, 2008 4:04 pm
by DataMystic Support
The trick is to pad the first CSV field to the maximum width (e.g. 30) using Filters\Restrict\Delimited fields (CSV, Tab, Pipe, etc) and Filters\Add\Pad to width, then do a count based on matching just this part of the line.