I am trying to make a program that uses the functions get_neg
and get_pos
to gather information about the file called project_twitter_data.csv
and create a a csv that contains the information about how many negative and positive words that there are. As you can see (I will copy/paste all my current code) on lines 4-7, I am just testing out trying to make a csv without any of the fancy stuff, but for some reason a get an error:
**
NotImplementedError: csv is not yet implemented in Skulpt on line 1
**
I then Googled "What is Skulpt" and got a fat percentage measurer website. Could somebody please explain to a Python noob what the error means and how to fix it?
(PS here is the code):
# import csv with open('resulting_data.csv', 'wb') as f: writer = csv.writer(f) writer.writerow(['first line', '2nd line']) punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@'] # lists of words to use positive_words = [] with open("positive_words.txt") as pos_f: for lin in pos_f: if lin[0] != ';' and lin[0] != '\n': positive_words.append(lin.strip()) negative_words = [] with open("negative_words.txt") as pos_f: for lin in pos_f: if lin[0] != ';' and lin[0] != '\n': negative_words.append(lin.strip()) twitter = [] with open("project_twitter_data.csv") as pos_f: for lin in pos_f: if lin[0] != ';' and lin[0] != '\n': twitter.append(lin.strip()) print(twitter) ####################### def strip_punctuation(x): lst = [] for letter in x: if not letter in punctuation_chars: lst.append(letter) return ("".join(lst)) ###################### def get_neg(x): lst = [] original_lst_name = [] var = 0 string = x.lower() original_lst_name = string.split(" ") print(original_lst_name) for letter in original_lst_name: if strip_punctuation(letter) in negative_words: var += 1 print(var) print(letter) return (var) ####################### def get_pos(x): lst = [] original_lst_name = [] var = 0 string = x.lower() original_lst_name = string.split(" ") print(original_lst_name) for letter in original_lst_name: if strip_punctuation(letter) in positive_words: var += 1 print(var) print(letter) return (var) #########################
https://stackoverflow.com/questions/65854974/why-is-csv-not-implemented-in-skulpt January 23, 2021 at 09:52AM
没有评论:
发表评论