Skip to content

Instantly share code, notes, and snippets.

@kirshiyin89
Last active June 16, 2021 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirshiyin89/069645eb6976b9367045fc9e15d1c7a1 to your computer and use it in GitHub Desktop.
Save kirshiyin89/069645eb6976b9367045fc9e15d1c7a1 to your computer and use it in GitHub Desktop.
Create word cloud without shape
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import csv
file_ob = open(r"feedback.csv")
# read the feedback file
reader_ob = csv.reader(file_ob)
reader_contents = list(reader_ob)
words = ""
for row in reader_contents :
for feedback in row :
words = words + " " + feedback
# build the WordCloud image
wordcloud = WordCloud(width = 800, height = 400, background_color ='orchid', colormap='Pastel1', random_state = 1, max_words = 20).generate(words)
# save the image
wordcloud.to_file("wordcloud.png")
# show the WordCloud image
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.margins(x=0, y=0)
plt.tight_layout(pad = 0)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment