Skip to content

Commit

Permalink
allow rtfd to build docs without needing to build larch
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Jan 2, 2015
1 parent 6d42465 commit 0e84b03
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# serve to show the default.

import sys, os
import larch

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -24,7 +23,7 @@
.. |sqlite_version| replace:: %(sqlite)s
.. |numpy_version| replace:: %(numpy)s
.. |scipy_version| replace:: %(scipy)s
""" % larch.versions
""" % {'larch': '3.10a-DEC2014-0-ga2c83bd', 'pandas': '0.14.1', 'apsw': '3.8.7.3-r1', 'python': '3.4.0 final', 'scipy': '0.14.0c1', 'sqlite': '3.8.7.4', 'numpy': '1.8.1'}

# -- General configuration -----------------------------------------------------

Expand Down
66 changes: 61 additions & 5 deletions doc/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,30 @@ In addition to opening an existing SQLite database directly, there are a number
methods available to create a :class:`DB` object without having it linked to an
original database file.

.. automethod:: DB.Copy
.. method:: DB.Copy

:param source: The source database.
:type source: str
:param destination: The destination database.
:type destination: str
:returns: A DB object with an open connection to the destination DB.

Create a copy of a database and link it to a DB object.
It is often desirable to work on a copy of your data, instead of working
with the original file. If you data file is not very large and you are
working with multiple models, there can be significant speed advantages
to copying the entire database into memory first, and then working on it
there, instead of reading from disk every time you want data.


.. method:: DB.Example

Generate an example data object in memory.
Larch comes with a few example data sets, which are used in documentation
and testing. It is important that you do not edit the original data, so
this function copies the data into an in-memory database, which you can
freely edit without damaging the original data.

.. automethod:: DB.Example



Expand All @@ -40,11 +61,46 @@ Importing Data
There are a variety of methods available to import data from external sources into
a SQLite table for use with the larch DB facility.

.. automethod:: DB.import_csv
.. method:: DB.import_csv

Import raw csv or tab-delimited data into SQLite.

:param rawdata: The absolute path to the raw csv or tab delimited data file.
:param table: The name of the table into which the data is to be imported
:param drop_old: Bool= drop old data table if it already exists?
:param progress_callback: If given, this callback function takes a single integer
as an argument and is called periodically while loading
with the current precentage complete.

:result: A list of column headers from the imported csv file


.. automethod:: DB.import_dataframe
.. method:: DB.import_dataframe

.. automethod:: DB.import_dbf
Imports data from a pandas dataframe into an existing larch DB.

:param rawdataframe: An existing pandas dataframe.
:param table: The name of the table into which the data is to be imported
:param if_exists: Should be one of {‘fail’, ‘replace’, ‘append’}. If the table
does not exist this parameter is ignored, otherwise,
*fail*: If table exists, raise a ValueError exception.
*replace*: If table exists, drop it, recreate it, and insert data.
*append*: If table exists, insert data.

:result: A list of column headers from imported pandas dataframe


.. method:: DB.import_dbf

Imports data from a DBF file into an existing larch DB.

:param rawdata: The path to the raw DBF data file.
:param table: The name of the table into which the data is to be imported
:param drop_old: Bool= drop old data table if it already exists?

:result: A list of column headers from imported csv file

Note: this method requires the dbfpy module (available using pip).



Expand Down

0 comments on commit 0e84b03

Please sign in to comment.