diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/index.rst | 13 | ||||
| -rw-r--r-- | docs/install.rst | 12 | ||||
| -rw-r--r-- | docs/intro.rst | 3 | ||||
| -rw-r--r-- | docs/tutorial.rst | 30 |
4 files changed, 34 insertions, 24 deletions
diff --git a/docs/index.rst b/docs/index.rst index 55e5679..90289e2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -29,18 +29,23 @@ Tablib is an :ref:`MIT Licensed <mit>` format-agnostic tabular dataset library, >>> data = tablib.Dataset(headers=['First Name', 'Last Name', 'Age']) >>> for i in [('Kenneth', 'Reitz', 22), ('Bessie', 'Monke', 21)]: ... data.append(i) - - >>> print data.json + + >>> print(data.export('json')) [{"Last Name": "Reitz", "First Name": "Kenneth", "Age": 22}, {"Last Name": "Monke", "First Name": "Bessie", "Age": 21}] - >>> print data.yaml + >>> print(data.export('yaml')) - {Age: 22, First Name: Kenneth, Last Name: Reitz} - {Age: 21, First Name: Bessie, Last Name: Monke} - >>> data.xlsx + >>> data.export('xlsx') <censored binary data> + >>> data.export('df') + First Name Last Name Age + 0 Kenneth Reitz 22 + 1 Bessie Monke 21 + Testimonials ------------ diff --git a/docs/install.rst b/docs/install.rst index 365cca8..a236b87 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -16,7 +16,7 @@ Distribute & Pip Of course, the recommended way to install Tablib is with `pip <http://www.pip-installer.org/>`_:: - $ pip install tablib + $ pip install tablib[pandas] ------------------- @@ -40,16 +40,6 @@ To download the full source history from Git, see :ref:`Source Control <scm>`. .. _zipball: http://github.com/kennethreitz/tablib/zipball/master -.. _speed-extensions: -Speed Extensions ----------------- - -You can gain some speed improvement by optionally installing the ujson_ library. -Tablib will fallback to the standard `json` module if it doesn't find ``ujson``. - -.. _ujson: https://pypi.python.org/pypi/ujson - - .. _updates: Staying Updated --------------- diff --git a/docs/intro.rst b/docs/intro.rst index e3da4dc..6af436d 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -49,7 +49,7 @@ Tablib is released under terms of `The MIT License`_. Tablib License -------------- -Copyright 2016 Kenneth Reitz +Copyright 2017 Kenneth Reitz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -77,7 +77,6 @@ Pythons Supported At this time, the following Python platforms are officially supported: -* cPython 2.6 * cPython 2.7 * cPython 3.3 * cPython 3.4 diff --git a/docs/tutorial.rst b/docs/tutorial.rst index d552e21..1fe11ee 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -115,30 +115,38 @@ Tablib's killer feature is the ability to export your :class:`Dataset` objects i **Comma-Separated Values** :: - >>> data.csv + >>> data.export('csv') Last Name,First Name,Age Reitz,Kenneth,22 Monke,Bessie,20 **JavaScript Object Notation** :: - >>> data.json + >>> data.export('json') [{"Last Name": "Reitz", "First Name": "Kenneth", "Age": 22}, {"Last Name": "Monke", "First Name": "Bessie", "Age": 20}] **YAML Ain't Markup Language** :: - >>> data.yaml + >>> data.export('yaml') - {Age: 22, First Name: Kenneth, Last Name: Reitz} - {Age: 20, First Name: Bessie, Last Name: Monke} **Microsoft Excel** :: - >>> data.xls + >>> data.export('xls') <censored binary data> +**Pandas DataFrame** :: + + >>> data.export('df') + First Name Last Name Age + 0 Kenneth Reitz 22 + 1 Bessie Monke 21 + + ------------------------ Selecting Rows & Columns ------------------------ @@ -216,7 +224,7 @@ Let's add a dynamic column to our :class:`Dataset` object. In this example, we h Let's have a look at our data. :: - >>> data.yaml + >>> data.export('yaml') - {Age: 22, First Name: Kenneth, Grade: 0.6, Last Name: Reitz} - {Age: 20, First Name: Bessie, Grade: 0.75, Last Name: Monke} @@ -246,7 +254,7 @@ For example, we can use the data available in the row to guess the gender of a s Adding this function to our dataset as a dynamic column would result in: :: - >>> data.yaml + >>> data.export('yaml') - {Age: 22, First Name: Kenneth, Gender: Male, Last Name: Reitz} - {Age: 20, First Name: Bessie, Gender: Female, Last Name: Monke} @@ -281,6 +289,14 @@ Now that we have extra meta-data on our rows, we can easily filter our :class:`D It's that simple. The original :class:`Dataset` is untouched. +Open an Excel Workbook and read first sheet +-------------------------------- + +To open an Excel 2007 and later workbook with a single sheet (or a workbook with multiple sheets but you just want the first sheet), use the following: + +data = tablib.Dataset() +data.xlsx = open('my_excel_file.xlsx', 'rb').read() +print(data) Excel Workbook With Multiple Sheets ------------------------------------ @@ -346,7 +362,7 @@ When, it's often useful to create a blank row containing information on the upco # Write spreadsheet to disk with open('grades.xls', 'wb') as f: - f.write(tests.xls) + f.write(tests.export('xls')) The resulting **tests.xls** will have the following layout: |
