In [1]:
# !pip install fake-factory ;# not pip install faker

In [2]:
from faker import Factory
import csv
import sys

In [3]:
def foo(filename, n):
    with open(filename, 'w') as f:
        for _ in range(n):
            fake = Factory.create()
            name = fake.profile()['name']
            address_raw = fake.profile()['address']
            address = address_raw.replace('\n', ', ')
            birthdate = fake.profile()['birthdate']
            phone = fake.phone_number()
            writer = csv.writer(f)
            writer.writerow((name, address, birthdate, phone))

In [4]:
filename = 'data.csv'
n = 3
foo(filename, n)
print(open(filename).read())


John Nguyen,"5683 Rodriguez Fork Suite 504, Kaufmanmouth, CT 85354-5732",1981-01-09,453-653-3706x42426
Jennifer Johnson,"31506 Morales Burg, New Micheal, IA 39308",2005-06-15,(886)901-9166x38446
Todd Leonard,"0719 Cruz Way Suite 595, Danielstad, MN 02681",2012-09-22,+20(3)7430225698


In [5]:
help(Factory)


Help on class Factory in module faker.factory:

class Factory(builtins.object)
 |  Class methods defined here:
 |  
 |  create(locale=None, providers=None, generator=None, includes=None, **config) from builtins.type
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)


In [6]:
import faker
help(faker)


Help on package faker:

NAME
    faker

PACKAGE CONTENTS
    __main__
    build_docs
    cli
    compat
    config
    data
    documentor
    factory
    generator
    patterns
    providers (package)
    shims (package)
    tests (package)
    utils (package)

DATA
    VERSION = '0.6.0'

FILE
    /home/doj/i/env3/lib/python3.4/site-packages/faker/__init__.py



In [7]:
help(faker.factory)


Help on module faker.factory in faker:

NAME
    faker.factory - # coding=utf-8

CLASSES
    builtins.object
        Factory
    
    class Factory(builtins.object)
     |  Class methods defined here:
     |  
     |  create(locale=None, providers=None, generator=None, includes=None, **config) from builtins.type
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)

DATA
    AVAILABLE_LOCALES = set(['bg_BG', 'bs_BA', 'cs_CZ', 'de_AT', 'de_DE', ...
    DEFAULT_LOCALE = 'en_US'
    PROVIDERS = ['faker.providers.address', 'faker.providers.barcode', 'fa...
    absolute_import = _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0...
    unicode_literals = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', ...

FILE
    /home/doj/i/env3/lib/python3.4/site-packages/faker/factory.py



In [8]:
help(Factory.create().profile)
# There is a docstring, but it is incomplete.


Help on method profile in module faker.providers.profile:

profile(fields=None, sex=None) method of faker.providers.profile.Provider instance
    Generates a complete profile.
    If "fields" is not empty, only the fields in the list will be returned


In [9]:
print(Factory.create().profile.__doc__)


        Generates a complete profile.
        If "fields" is not empty, only the fields in the list will be returned
        

In [10]:
fake = Factory.create().profile()

In [11]:
help(fake)


Help on dict object:

class dict(object)
 |  dict() -> new empty dictionary
 |  dict(mapping) -> new dictionary initialized from a mapping object's
 |      (key, value) pairs
 |  dict(iterable) -> new dictionary initialized as if via:
 |      d = {}
 |      for k, v in iterable:
 |          d[k] = v
 |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
 |      in the keyword argument list.  For example:  dict(one=1, two=2)
 |  
 |  Methods defined here:
 |  
 |  __contains__(self, key, /)
 |      True if D has a key k, else False.
 |  
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |  
 |  __eq__(self, value, /)
 |      Return self==value.
 |  
 |  __ge__(self, value, /)
 |      Return self>=value.
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  __getitem__(...)
 |      x.__getitem__(y) <==> x[y]
 |  
 |  __gt__(self, value, /)
 |      Return self>value.
 |  
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |  
 |  __iter__(self, /)
 |      Implement iter(self).
 |  
 |  __le__(self, value, /)
 |      Return self<=value.
 |  
 |  __len__(self, /)
 |      Return len(self).
 |  
 |  __lt__(self, value, /)
 |      Return self<value.
 |  
 |  __ne__(self, value, /)
 |      Return self!=value.
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
 |  
 |  __repr__(self, /)
 |      Return repr(self).
 |  
 |  __setitem__(self, key, value, /)
 |      Set self[key] to value.
 |  
 |  __sizeof__(...)
 |      D.__sizeof__() -> size of D in memory, in bytes
 |  
 |  clear(...)
 |      D.clear() -> None.  Remove all items from D.
 |  
 |  copy(...)
 |      D.copy() -> a shallow copy of D
 |  
 |  fromkeys(iterable, value=None, /) from builtins.type
 |      Returns a new dict with keys from iterable and values equal to value.
 |  
 |  get(...)
 |      D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
 |  
 |  items(...)
 |      D.items() -> a set-like object providing a view on D's items
 |  
 |  keys(...)
 |      D.keys() -> a set-like object providing a view on D's keys
 |  
 |  pop(...)
 |      D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
 |      If key is not found, d is returned if given, otherwise KeyError is raised
 |  
 |  popitem(...)
 |      D.popitem() -> (k, v), remove and return some (key, value) pair as a
 |      2-tuple; but raise KeyError if D is empty.
 |  
 |  setdefault(...)
 |      D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
 |  
 |  update(...)
 |      D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
 |      If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
 |      If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
 |      In either case, this is followed by: for k in F:  D[k] = F[k]
 |  
 |  values(...)
 |      D.values() -> an object providing a view on D's values
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __hash__ = None


In [12]:
fake.keys()


Out[12]:
dict_keys(['current_location', 'website', 'ssn', 'name', 'mail', 'residence', 'blood_group', 'address', 'birthdate', 'company', 'sex', 'username', 'job'])

In [13]:
fake


Out[13]:
{'address': '5951 Johnson Island\nPort Kristenland, SC 03144-4728',
 'birthdate': '1974-07-07',
 'blood_group': 'A+',
 'company': 'Brewer PLC',
 'current_location': (Decimal('84.696862'), Decimal('119.491742')),
 'job': 'Passenger transport manager',
 'mail': 'kgoodman@hotmail.com',
 'name': 'Terry Blanchard',
 'residence': '44355 George Springs Suite 597\nSouth Andreashire, KY 50790-9990',
 'sex': 'M',
 'ssn': '796-98-1810',
 'username': 'inixon',
 'website': ['http://www.holland-long.com/',
  'http://www.hampton.com/',
  'http://www.harper.com/']}