Skip to content

Commit

Permalink
removing pyexcel related documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed May 15, 2015
1 parent e0ca79e commit a03b13c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 191 deletions.
65 changes: 2 additions & 63 deletions doc/source/csvz.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ When a single sheet is to be saved, the resulting csvz file will be a zip file t
['pyexcel_sheet1.csv']
>>> zip.close()

.. note::

This is how you do it with pyexcel::
>>> import pyexcel as pe
>>> data = [[1,2,3]]
>>> sheet = pe.Sheet(data)
>>> sheet.save_as("myfile.csvz")

And it can be read out as well and can be saved in any other supported format.

Expand All @@ -42,17 +34,6 @@ And it can be read out as well and can be saved in any other supported format.
>>> json.dumps(data)
'[["1", "2", "3"]]'

.. note::

This is how to do it with pyexcel::

>>> sheet2 = pe.get_sheet(file_name="myfile.csvz")
>>> sheet2
Sheet Name: pyexcel
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+


Multiple Sheet Book
-------------------
Expand Down Expand Up @@ -91,57 +72,15 @@ When multiple sheets are to be saved as a book, the resulting csvz file will be
['Sheet 1.csv', 'Sheet 2.csv', 'Sheet 3.csv']
>>> zip.close()

.. note::

This is how you do it with pyexcel:

>>> book = pe.Book(content)
>>> book.save_as("mybook.csvz")
>>> import zipfile
>>> zip = zipfile.ZipFile("mybook.csvz", 'r')
>>> zip.namelist()
['Sheet 1.csv', 'Sheet 2.csv', 'Sheet 3.csv']
>>> zip.close()

The csvz book can be read back with two lines of code. And once it is read out, it can be saved in any other supported format.

>>> book2 = get_data("mybook.csvz")
>>> json.dumps(book2)
'{"Sheet 1": [["1.0", "2.0", "3.0"], ["4.0", "5.0", "6.0"], ["7.0", "8.0", "9.0"]], "Sheet 2": [["X", "Y", "Z"], ["1.0", "2.0", "3.0"], ["4.0", "5.0", "6.0"]], "Sheet 3": [["O", "P", "Q"], ["3.0", "2.0", "1.0"], ["4.0", "3.0", "2.0"]]}'

.. note::

This is how you do it with pyexcel

>>> book2 = pe.get_book(file_name="mybook.csvz")
>>> book2
Sheet Name: Sheet 1
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
| 7 | 8 | 9 |
+---+---+---+
Sheet Name: Sheet 2
+---+---+---+
| X | Y | Z |
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
Sheet Name: Sheet 3
+---+---+---+
| O | P | Q |
+---+---+---+
| 3 | 2 | 1 |
+---+---+---+
| 4 | 3 | 2 |
+---+---+---+


Open csvz without pyexcel

Open csvz without pyexcel-io
----------------------------

All you need is a unzipping software. I would recommend 7zip which is open source and is available on all available OS platforms.
Expand Down
68 changes: 0 additions & 68 deletions doc/source/extendedcsv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,78 +75,10 @@ Continue from previous example::
{"Sheet 1": [["1", "2", "3"], ["4", "5", "6"]], "Sheet 2": [["7", "8", "9"], ["10", "11", "12"]]}


As a pyexcel plugin
------------------------------------------------------------------------------


Reading from multiple sibling csv files
********************************************************************************

Here is the sample code::

>>> import pyexcel as pe
>>> from pyexcel.ext import io
>>> book = pe.get_book(file_name="your_file.csv")
>>> book
Sheet Name: Sheet 1
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
Sheet Name: Sheet 2
+-------+-------+-------+
| row 1 | row 2 | row 3 |
+-------+-------+-------+

Writing to multiple sibling csv files
********************************************************************************

Here is the sample code::

>>> book.save_as("another_file.csv")


Writing multiple sibling csv files to a StringIO instance
********************************************************************************

You need to pass a StringIO instance to Writer::

>>> io = StringIO()
>>> book.save_to_memory("csv", io)
>>> # then do something with io
>>> # In reality, you might give it to your http response
>>> # object for downloading


Reading multiple sibling csv files from a IO instance
********************************************************************************

You got to wrap the binary content with stream to get csv working::

>>> # This is just an illustration
>>> # In reality, you might deal with csv file upload
>>> # where you will read from requests.FILES['YOUR_CSV_FILE']
>>> memory_book = pe.get_book(file_type="csv", file_stream=io)
>>> memory_book
Sheet Name: Sheet 1
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
Sheet Name: Sheet 2
+-------+-------+-------+
| row 1 | row 2 | row 3 |
+-------+-------+-------+


.. testcode::
:hide:

>>> import os
>>> os.unlink("your_file__Sheet 1__0.csv")
>>> os.unlink("your_file__Sheet 2__1.csv")
>>> os.unlink("another_file__Sheet 1__0.csv")
>>> os.unlink("another_file__Sheet 2__1.csv")

60 changes: 0 additions & 60 deletions doc/source/plaincsv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,70 +60,10 @@ Continue from previous example::
[["1", "2", "3"], ["4", "5", "6"]]


As a pyexcel plugin
--------------------------------------------------------------------------------

**pyexcel** builds on top of pyexcel-io and provides more data manipulation
functions. The following sections show how to do the same via pyexcel apis.

Reading from multiple csv file
********************************************************************************

Here is the sample code::

>>> import pyexcel as pe
>>> sheet = pe.get_sheet(file_name="your_file.csv")
>>> sheet
Sheet Name: your_file.csv
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+

Writing to multiple sibling csv files
*******************************************************************************

Here is the sample code::

>>> sheet.save_as("another_file.csv")


Writing to a StringIO instance
********************************************************************************

You need to pass a StringIO instance to Writer::

>>> io = StringIO()
>>> sheet.save_to_memory("csv", io)
>>> # then do something with io
>>> # In reality, you might give it to your http response
>>> # object for downloading


Reading from a IO instance
********************************************************************************

You got to wrap the binary content with stream to get csv working::

>>> # This is just an illustration
>>> # In reality, you might deal with csv file upload
>>> # where you will read from requests.FILES['YOUR_CSV_FILE']
>>> memory_sheet = pe.get_book(file_type="csv", file_stream=io)
>>> memory_sheet
Sheet Name: csv
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+



.. testcode::
:hide:

>>> import os
>>> os.unlink("your_file.csv")
>>> os.unlink("another_file.csv")

0 comments on commit a03b13c

Please sign in to comment.