Coder Social home page Coder Social logo

i3visio / pyexcel-text Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pyexcel-renderers/pyexcel-text

0.0 1.0 0.0 30 KB

It is a plugin to pyexcel and provides the capbility to present and write data in text fromats

License: Other

Makefile 0.19% Python 98.63% Batchfile 0.56% Shell 0.62%

pyexcel-text's Introduction

pyexcel-text - Let you focus on data, instead of text format

image

image

It is a plugin to pyexcel and extends its capbility to present and write data in text fromats mainly through `tabulate`:

  • "plain"
  • "simple"
  • "grid"
  • "pipe"
  • "orgtbl"
  • "rst"
  • "mediawiki"
  • "latex"
  • "latex_booktabs"
  • "json"

Usage

>>> import pyexcel as pe >>> import pyexcel.ext.text as text >>> content = [ ... ["Column 1", "Column 2", "Column 3"], ... [1, 2, 3], ... [4, 5, 6], ... [7, 8, 9] ... ] >>> sheet = pe.Sheet(content) >>> sheet Sheet Name: pyexcel -------- -------- --------Column 1 Column 2 Column 3 1 2 3 4 5 6 7 8 9 -------- -------- -------->>> sheet.name_columns_by_row(0) >>> sheet Sheet Name: pyexcel Column 1 Column 2 Column 3 ---------- ---------- ---------- 1 2 3 4 5 6 7 8 9 >>> text.TABLEFMT = "grid" >>> sheet Sheet Name: pyexcel +------------+------------+------------+ | Column 1 | Column 2 | Column 3 | +============+============+============+ | 1 | 2 | 3 | +------------+------------+------------+ | 4 | 5 | 6 | +------------+------------+------------+ | 7 | 8 | 9 | +------------+------------+------------+ >>> multiple_sheets = { ... '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] ... ] ... } >>> book = pe.Book(multiple_sheets) >>> text.TABLEFMT = "mediawiki" >>> book.save_as("myfile.mediawiki") >>> myfile = open("myfile.mediawiki") >>> print(myfile.read()) Sheet Name: Sheet 1 {| class="wikitable" style="text-align: left;" -| align="right"| 1 || align="right"| 2 || align="right"| 3 align="right"| 4 || align="right"| 5 || align="right"| 6 align="right"| 7 || align="right"| 8 || align="right"| 9 class="wikitable" style="text-align: left;" -| X || Y || Z 1.0 || 2.0 || 3.0 4.0 || 5.0 || 6.0 class="wikitable" style="text-align: left;" -| O || P || Q 3.0 || 2.0 || 1.0 4.0 || 3.0 || 2.0 |} <BLANKLINE>

>>> myfile.close() >>> import os >>> os.unlink("myfile.mediawiki")

Dependencies

  • tabulate

pyexcel-text's People

Contributors

chfw avatar i3visio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.