954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Summing lines in a text file

Hi, I am looking for advice on the best way to achieve my current goal.
I am reading a textfile and extracting information from each line. For example string1 and string2. I am then writing these string to a datatable.
However, sometimes there will be repeats in string1 and string2.
If there are repeated lines I would like to be able to delete the repeating line and add a counter to find the total number of repeating lines.
so if a string repeates 3 times I would like there to be a column with a 3 displayed next to the line in my datatable.
If anyone has any suggestion on the best approach or some example code I would very much appreciate this.

Best,
Starlight849

starlight849
Light Poster
29 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Anyone?
I'm comparing two arrays of strings. If string 2 matches string 1 more than once then I delete the repeating strings in both. I then add a counter to see how many times the matches appear.

Example:
string1 string2
apple orange
apple banana
apple pear
mango banana
mango banana

I only want to delete the second occurence of mango banana. I then need a total count of mango banana (2).

starlight849
Light Poster
29 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

I've added the strings to a datatable and am going to loop through the datatable to do this search. If anyone has any example about comparing and declaring a previous and current row in a datatable I would appreciate it.

starlight849
Light Poster
29 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Problem solved.

starlight849
Light Poster
29 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: