Browse Source

Output the statistics for .csv output

Xi Ruoyao 5 năm trước cách đây
mục cha
commit
9782391717
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 7 0
      wordfreq.py

+ 7 - 0
wordfreq.py

@@ -79,6 +79,13 @@ def main():
     if args.debug:
         print(c)
 
+    # recognize .csv output and skip wordcloud
+    if args.output[-4:] == '.csv':
+        with open(args.output, mode="w") as ofile:
+            for i in c:
+                ofile.write(i + ',' + str(c[i]) + '\n')
+        return
+
     mask = None
     if not args.mask is None:
         from PIL import Image