2

I am new to python and am trying to build a product review analyzer with it. The program should look at the string(review) given and count the number of positive and negative feedback words by looking at my CSV dataset:

import csv

with open("data.csv", "r") as file:
    data = csv.reader(file, delimiter=",")

str = "Without it we wouldn't have the growing selection of electric vehicles we have today, yet the 2022 Tesla Model S remains one of the most compelling and desirable options in that growing market segment."

def wordCount(word):
    positive = []
    negative = []
    avoided = word.split()
    print("There are", len(avoided), "words in this string")
    for i in avoided:
        if i in data["positives"]:
            positive.append(i)
        elif i in data["negatives"]:
            negative.append(i)
    print(positive, negative)

wordCount(str)

But when I try to run this program, I receive this error:

TypeError: '_csv.reader' object is not subscriptable

And here's my dataset:

positive,negative
Adaptable,Abrasive
Adventurous,Apathetic
Amazing,Controlling
Amiable,Dishonest
Beautiful,Impatient
Becoming,Anxious
Beloved,Betrayed
Blessed,Disappointed
Blissful,Embarrassed
Brotherly,Jealous
Calming,Abysmal
Captivating,Bad
Charming,Callous
Cherished,Corrosive
Comforting,Damage
Compelling,Despicable
Considerable,Don’t
Credible,Enraged
Dapper,Fail
Darling,Gawky
Delicious,Haggard
Delightful,Hurt
Dependable,Icky
Desirable,Insane
Dreamy,Jealous
Durable,Lose
Elegant,Malicious
Empowering,Naive
Enchanting,Not
Endearing,Objectionable
Energising,Pain
Enjoyable,Questionable
Enlightening,Reject
Exceptional,Rude
Fabulous,Sad
Fancy,Sinister
Fantastic,Stuck
Fashionable,Tense
Faultless,Ugly
Fetching,Unsightly
Flourishing,Vice
Formidable,Wary
Fulfilling,Yell
Funny,Zero
Generous,Adverse
Gifted,Banal
Glamorous,Can’t
Gleaming,Corrupt
Glowing,Damaging
Godly,Detrimental
Gracious,Dreadful
Gratifying,Eroding
Happening,Faulty
Harmonious,Ghastly
Heavenly,Hard
Honourable,Hurtful
Ideal,Ignorant
Important,Insidious
Incredible,Junky
Indispensable,Lousy
Indisputable,Mean
Influential,Nasty
Inspiring,Noxious
Interesting,Odious
Irresistible,Perturb
Joyful,Quirky
Jolly,Renege
Jovial,Ruthless
Kindly,Savage
Kingly,Slimy
Leading,Stupid
Legendary,Terrible
Liberating,Undermine
Likeable,Untoward
Lordly,Vicious
Lovable,Weary
Luscious,Yucky
Luxurious,Alarming
Magical,Barbed
Majestic,Clumsy
Memorable,Dastardly
Mesmerizing,Dirty
Mighty,Dreary
Miraculous,Evil
Motivational,Fear
Obliging,Grave
Optimal,Hard-hearted
Original,Ignore
Out of this world,Injure
Outgoing,Insipid
Palatable,Lumpy
Paramount,Menacing
Peaceful,Naughty
Peachy,None
Perfect,Offensive
Phenomenal,Pessimistic
Picturesque,Quit
Pleasant,Repellant
Pleasing,Scare
Pleasurable,Smelly
Positive,Substandard
Powerful,Terrifying
Praiseworthy,Unfair
Precious,Unwanted
Prestigious,Vile
Prizewinning,Wicked
Promising,Angry
Quality,Belligerent
Radiant,Coarse
Reasonable,Crazy
Refreshing,Dead
Reliable,Disease
Respectable,Feeble
Revolutionary,Greed
Rewarding,Harmful
Rousing,Ill
Saintly,Injurious
Salubrious,Messy
Satisfying,Negate
Scrumptious,No one
Sensational,Old
Sexy,Petty
Shiny,Reptilian
Showy,Scary
Smashing,Sobbing
Soothing,Suspect
Sought-after,Threatening
Spectacular,Unfavorable
Spiffy,Unwelcome
Stimulating,Villainous
Striking,Woeful
Stunning,Annoy
Stupendous,Bemoan
Superb,Cold
Supreme,Creepy
Swanky,Decaying
Tasteful,Disgusting
Tasty,Fight
Terrific,Grim
Thrilling,Hate
Titillating,Immature
Tremendous,Misshapen
Trusty,Negative
Ultimate,Nothing
Unbelievable,Oppressive
Uplifting,Plain
Useful,Repugnant
Valuable,Scream
Vibrant,Sorry

Can someone please help me? I have a project and am kinda in a hurry:)

memos815
  • 31
  • 3

0 Answers0