我有这个csv文件
Cat, and, dog, bites
Yahoo, news, claims, a, cat, mated, with, a, dog, and, produced, viable, offspring
Cat, killer, likely, is, a, big, dog
Professional, free, advice, on, dog, training, puppy, training
Cat, and, kitten, training, and, behavior
Dog, &, Cat, provides, dog, training, in Eugene, Oregon
Dog, and, cat, is, a, slang, term, used, by, police, officers, for, a, male-female, relationship
Shop, for, your, show, dog, grooming, and, pet, supplies
我想让所有单词以小写字母开头,并创建一个列表,其中包含上述csv文件中的所有唯一项目。 你知道吗?提前致谢! 到目前为止,我已设法用一个小写字母转换所有单词:
unique_row_items = set([field.strip().lower() for field in row])
但我无法管理另一个。
def unique():
rows = list(csv.reader(open('example_1.csv', 'r'), delimiter=','))
result = []
for r in rows:
key = r
if key not in result:
result.append(r)
return result
哪个没有给出我想要的结果