Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install z3c.gibberish

How to install z3c.gibberish

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install z3c.gibberish
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1 Available View build log
Windows (64-bit)
0.1 Available View build log
Mac OS X (10.5+)
0.1 Available View build log
Linux (32-bit)
0.1 Available View build log
Linux (64-bit)
0.1 Available View build log
 
License
GPL
Dependencies
Imports
Lastest release
version 0.1 on Jan 5th, 2011

Generate CSV files containing random words from a dictionary

Get the script from the buildout:

>>> import os
>>> gibberish = os.path.join(

System Message: ERROR/3 (<string>, line 11)

Inconsistent literal block quoting.

... reduce(lambda path, _: os.path.dirname(path), ... range(3), __file__), 'bin', 'gibberish')

Print the help:

>>> from zc.buildout.testing import system
>>> print system(gibberish+' --help'),

System Message: ERROR/3 (<string>, line 18)

Inconsistent literal block quoting.

usage: gibberish [options] LINES COLUMN [COLUMN ...] <BLANKLINE> Generate lines of CSV consisting of random words from a dictionary. The number of lines of CSV must be specified either as a single integer to specify a fixed number of lines or two integers separated by a dash to specify that a random number of lines between the two integers should be used. The columns are specified in the same manner where the numbers represent the number of words in that column for a given line. <BLANKLINE> options: -h, --help show this help message and exit -w WORDS, --words=WORDS File containing the words to be chosen from [default: /usr/share/dict/words]

Make a simple file with one line and one column containing one word:

>>> import cStringIO, csv
>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 38)

Inconsistent literal block quoting.

... system(gibberish+' 1 1')))) >>> len(result) 1 >>> len(result[0]) 1 >>> len(result[0][0].split()) 1

Make sure that the newline is stripped:

>>> result[0][0][-1] != '\n'

System Message: ERROR/3 (<string>, line 49)

Inconsistent literal block quoting.

True

With two words in the column:

>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 54)

Inconsistent literal block quoting.

... system(gibberish+' 1 2')))) >>> len(result) 1 >>> len(result[0]) 1 >>> len(result[0][0].split()) 2

With a random number of words in the column:

>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 65)

Inconsistent literal block quoting.

... system(gibberish+' 1 1-10')))) >>> len(result) 1 >>> len(result[0]) 1 >>> 1 <= len(result[0][0].split()) <= 10 True

With 10 lines:

>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 76)

Inconsistent literal block quoting.

... system(gibberish+' 10 2')))) >>> len(result) 10 >>> len(result[0]) 1 >>> len(result[0][0].split()) 2

With a random number of lines:

>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 87)

Inconsistent literal block quoting.

... system(gibberish+' 1-10 2')))) >>> 1 <= len(result) <= 10 True >>> len(result[0]) 1 >>> len(result[0][0].split()) 2

With two columns:

>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 98)

Inconsistent literal block quoting.

... system(gibberish+' 1 2 3')))) >>> len(result) 1 >>> len(result[0]) 2 >>> len(result[0][0].split()) 2 >>> len(result[0][1].split()) 3

With a random number of words including zero in the column:

>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 111)

Inconsistent literal block quoting.

... system(gibberish+' 1 0-1')))) >>> len(result) 1 >>> len(result[0]) 1 >>> len(result[0][0].split()) in (0, 1) True

With a small dictionary to test exhausting the dictionary:

>>> import tempfile
>>> _, tmp_path = tempfile.mkstemp()
>>> tmp = file(tmp_path, 'w')
>>> tmp.write('foo')
>>> tmp.close()
>>> result = tuple(csv.reader(cStringIO.StringIO(

System Message: ERROR/3 (<string>, line 127)

Inconsistent literal block quoting.

... system(gibberish+' -w %s 1 1' % tmp_path)))) >>> result (['foo'],) >>> os.remove(tmp_path)

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.