Count the number of times a line is in a file

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

gotcher
Posts: 1
Joined: Fri May 23, 2008 4:37 am

Count the number of times a line is in a file

Postby gotcher » Fri May 23, 2008 4:51 am

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.

User avatar
DataMystic Support
Site Admin
Posts: 2164
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

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

Postby DataMystic Support » Thu May 29, 2008 4:04 pm

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

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Baidu [Spider] and 11 guests