I have a question about the best way to get word counts for items in a list.
I have 400+ items indexed in a list. They are of varying lengths. For example, if I enumerate, then I will get:
for index, items in enumerate(my_list):
print index, items
0 fish, line, catch, hook
1 boat, wave, reel, line, fish, bait
.
.
.
Each item will get written into individual rows in an csv file. I would like corresponding word counts to complement this text in the adjacent column. I can find word/token counts just fine using Excel, but I would like to be able to do this in Python so I don’t have to keep going back and forth between programs to process my data.
I’m sure there are several ways to do this, but I can’t seem to piece together a good solution. Any help would be appreciated.
As was posted in the comments, it’s not really clear what your goal is here, but if it is to print a csv file that has one word per row along with each word’s length,
If I’m misunderstanding here and actually what you have is a list of strings in which each string contains a list of comma-separated words, what you’d want to do instead is: