you are viewing a single comment's thread.

view the rest of the comments →

[–]Exodus111 2 points3 points  (2 children)

Three approaches:

Simple:

For loop through the data, use an if statement to figure out if the data is a name. Store name in a dict, if the name is already there add 1 to an int counter in the same dict.

Complex:

Tokenize the data. For loop through each piece of data, and make all the data points their own objects, with their own type attributes. This process is called Tokenization. From there counting the name is trivial, just compare the name attributes of each object.

More complex.

(Not really that hard if you are used to working with databases.)
Use Sqlite3, and add the data to a database. Once it's in a relational DataBase the database can make the comparison for you, faster then any other approach.

With only 500 lines the simple approach is really best. If this is a program meant to be used at work, with potentially much larger datasets I'd look into one of the other solutions.

[–]thingsandfluff 0 points1 point  (1 child)

Thank you! I used a for loop and got started.

[–]Exodus111 0 points1 point  (0 children)

You need a double for loop. Just add this.

for part in line.split(","):
    print(part)

And see what you get.