GithubHelp home page GithubHelp logo

word-clouds's Introduction

Word Cloud Parser

A small script to combine multiple world cloud CSVs into one file.

Requirements

The script was writtng using Python 2.7 and requires the following modules (generally available in the standard library):

  • os
  • csv
  • re
  • argparse

Filename Structure

The script expects all the CSV files that are to be combined to have the following filename structure:

[keword] [source].csv

Examples
  • abortion blog.csv
  • gun control twitter.csv
  • potus traditional media.csv

Any filename that does not follow this structure will be ignored.

Installation

Download the combine-clouds.py file and place it in the same directory as the CSV files you wish to process.

Usage

The script should be run from the command line.

First, navigate to the folder where you placed the script.

Next, you can run the script on OSX and Linux by typing:

python combine-clouds.py

On Windows, typing python in the command line will only work if you have set your path variable accordingly. Othwerwise, the default install for the python.exe file is c:\Python27\python. So try the following line for Windows:

c:\Python27\python combine-clouds.py

Simply calling this script, though, will only produce a help message. To combine some files you need to pass some flags to the file.

Available Flags

The script accepts 3 flags

  • -a, --all

    • This flag overrides all other flags. It tells the script to use process all of the files in the directory. The default sources are "blog", "traditional media", "twitter", and "forum". It uses these sources to parse each filename and determine all of the unique keywords.

    • Example:

      python combine-clouds.py --all

  • -k, --keywords

    • This flag tells the script which keyword to process. It can take n keywords, each in quotes, and separated by a space

    • Example:

      python combine-clouds.py --keywords "abortion" "crime" "gun control"

  • -s, --sources

    • This flag sets different sources use when looking through the files. The default sources are "blog", "traditional media", "twitter", and "forum".

    • Example:

      python combine-clouds.py --sources "news" "televsion" "facebook"

Other usage examples

This command processes all the files for the keyword "gun control" using the default sources ("blog", "traditional media", "twitter", and "forum"):

python combine-clouds.py -k "gun control"

This command process all of the files in the current directory:

python combine-clouds.py -a

This command processes all the files for the keywords "gun control" and "election" using the sources "blog", "twitter", and "reddit":

python combine-clouds.py -k "gun control" "election" -s "blog" "twitter" "reddit

word-clouds's People

Contributors

jpobley avatar

Stargazers

Christopher Konopka avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.