Created
September 7, 2018 17:44
-
-
Save nkhine/c4b7c9a98fced7d306b1ae6199ba075c to your computer and use it in GitHub Desktop.
pyexcel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) | |
[GCC 7.3.0] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import pyexcel as p | |
>>> dict_list=[{'alfa':['001','2'], 'beta':['001','3'], 'gamma':['001','2']}, | |
... {'alfa':['002','6'], 'beta':['002','4'], 'omega':['002','7']}] | |
>>> | |
>>> s = p.Sheet() | |
>>> for d in dict_list: | |
... s.row += p.get_sheet(adict=d, transpose_after=True) | |
... | |
>>> s.colnames = ['WORD', 'TXT', 'FREQ'] | |
>>> s | |
pyexcel sheet: | |
+-------+-----+------+ | |
| WORD | TXT | FREQ | | |
+=======+=====+======+ | |
| alfa | 001 | 2 | | |
+-------+-----+------+ | |
| beta | 001 | 3 | | |
+-------+-----+------+ | |
| gamma | 001 | 2 | | |
+-------+-----+------+ | |
| alfa | 002 | 6 | | |
+-------+-----+------+ | |
| beta | 002 | 4 | | |
+-------+-----+------+ | |
| omega | 002 | 7 | | |
+-------+-----+------+ | |
>>> s.save_as('output.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment