Giter Club home page Giter Club logo

csvtotable's Introduction

CSVtoTable

Codacy Badge

Simple command-line utility to convert CSV files to searchable and sortable HTML table. Supports large datasets and horizontal scrolling for large number of columns.

Demo

Here is a demo of sample csv file converted to HTML table.

https://raw.githubusercontent.com/vividvilla/csvtotable/master/sample/table.gif

Installation

pip install --upgrade csvtotable

Get started

csvtotable --help

Convert data.csv file to data.html file

csvtotable data.csv data.html

Open output file in a web browser instead of writing to a file

csvtotable data.csv --serve

Options

-c,  --caption          Table caption
-d,  --delimiter        CSV delimiter. Defaults to ','
-q,  --quotechar        Quote chracter. Defaults to '"'
-dl, --display-length   Number of rows to show by default. Defaults to -1 (show all rows)
-o,  --overwrite        Overwrite the output file if exists. Defaults to false.
-s,  --serve            Open html output in a web browser.
-h,  --height           Table height in px or in %. Default is 75% of the page.
-p,  --pagination       Enable/disable pagination. Enabled by default.
-vs, --virtual-scroll   Number of rows after which virtual scroll is enabled. Default is set to 1000 rows.
                        Set it to -1 to disable and 0 to always enable.
-nh, --no-header        Show default headers instead of picking first row as header. Disabled by default.
-e,  --export           Enable filtered rows export options.
-eo, --export-options   Enable specific export options. By default shows all.
                        For multiple options use -eo flag multiple times. For ex. -eo json -eo csv

Credits

Datatables

csvtotable's People

Contributors

codacy-badger avatar hideoyukutake avatar vividvilla avatar youyanggu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csvtotable's Issues

Read from STDIN, STDOUT and from URL

Should be possible to pass CSV/JSON data in STDIN or read from STDOUT of another command or from URL download. This helps in visualizing JSON or CSV responses

Is it possible to add hyperlinks on cells ?

For example,there is a csv file :

link,title,description,date
http://github.com/1,title1,1,20170815
http://github.com/2,title2,2,20170815
http://github.com/3,title3,3,20170815
http://github.com/4,title4,4,20170814

output should like this:

title description date
title1 1 20170815
title2 2 20170815
title3 3 20170815
title4 4 20170814

This file was made by

Would it be possible for the next version to include in the final html a line
<!-- This file was made by csvtotable https://github.com/vividvilla/csvtotable -->
?
Knowlegeable visitors to my pages have been asking me how it was done ...

Can I externally link javascript and css in csvtotable

Can I link javascript and css from html file like this:

<script src="jQuery.min.js"></script> <script src="dataTables.js"></script> <script src="scroller.js"></script> <script src="Buttons.js"></script> <script src="csv2table.js"></script>

I have tried this. not working.

hide table until making a search

I have a table with over 50,000 rows, and growing... Having so much makes the page take an extreme amount of time to load... Is there any way of not showing the table until a search is made, sorta like google/youtube etc. ?

Cannot limit row size based on limit

If I have a file called "t.csv", to create "t.html", and "t.csv" is approx 143 lines in length, and I want to paginate every 20 row, I am guessing that the syntax is as follows:

csvtotable ./t.csv ./t.html -p -o -vs 20

Somehow, it remains as infinite virtual scrolling, rather than limiting to 20 rows. Am I doing something wrong, or was this intented to always be infinite scrolling?

Why does is the HTML not 'active' (jQueryUI, et. al)?

OK, I was able to use the workaround, then also did the upgrade; in both circumstances, I was able to generate HTML. However...upon taking closer look at the actual output file, it looks like it uses "jQueryUI" and another JavaScript-embedded script. It should be actively displaying the information (sorting, searching, etc.)

I was unable to see this done. What am I doing wrong?

aligment in column

Hi!
Is it possible to align the columns with digits to right?
Thanks,
Sergiy

field larger than field limit error.

Hey

I am facing this issue while using the csvtotable tool.
File "/home/sahaji/.local/lib/python2.7/site-packages/unicodecsv/py2.py", line 117, in next
row = self.reader.next()
_csv.Error: field larger than field limit (131072)

Is there a way to increase the field limit? It would be easy to do if it was read from a config file.
Similarly, for a larger number of rows, I got a memory error. How to allocate more memory?

Issue with conversion...

Am getting an "Aborted!" error message.

I saved the file as UTF-8 text, then converted it to CSV. The output from the process is shown below.

[root@server ~]# csvtotable t.csv t.html
Aborted!
[root@server ~]# more t.csv
ABC,12.34,T,1
ABC,12.31,F,2
ABC,12.40,T,3
ABC,12.32,T,4

BTW, I am running CentOS 7, with Python development kit, patched, and latest updates (via yum). There were no errors during the install.

Changes file

Hi! This is really useful tool.
The change-log any kind will be very useful. To track what's going on and what a new release gives me.

Thanks

Feature idea: ability to view HTML file without saving to a file

It would be nice if this tool could be used without having to delete the HTML file afterwards (when you're done reviewing the CSV file).

For example, you'd run csvtotable my_file.csv --view (or similar) and view the HTML page in your browser directly without writing it to a file (similar to how you can run a webserver by doing python -m http.server 8000).

getting started error

In getting started (README) it says csvtohtml and I think you meant csvtotable

On a separate issue, first CSV I tried it on I get a char encoding issue. The CSV is not public so I can't attach it, but I'm sure you can find some that contain utf8 chars

Traceback (most recent call last):
  File "/usr/local/bin/csvtotable", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/csvtotable/cli.py", line 30, in cli
    delimiter=delimiter, quotechar=quotechar)
  File "/usr/local/lib/python2.7/dist-packages/csvtotable/convert.py", line 48, in convert
    for row in reader:
  File "/usr/local/lib/python2.7/dist-packages/backports/csv.py", line 394, in __next__
    lineobj = next(self.input_iter)
  File "/usr/lib/python2.7/codecs.py", line 314, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf4 in position 818: invalid continuation byte

UTF-16 is not supported

Hi! First, thanks for this project, it served my goal very well!

When using an UTF-16 file, it prints the error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

When converting the file to UTF-8 using iconv it works fine.

Support for tab delimiter

Is there a way to specify the tab character as the delimiter in the CLI?

If I run

$ csvtotable <tabseperatedcsv.csv> /tmp/out.html -d '\t'

the following error occurs:

Traceback (most recent call last):
  File "/usr/bin/csvtotable", line 11, in <module>
    load_entry_point('csvtotable==1.1.0', 'console_scripts', 'csvtotable')()
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/csvtotable/cli.py", line 30, in cli
    delimiter=delimiter, quotechar=quotechar)
  File "/usr/lib/python2.7/site-packages/csvtotable/convert.py", line 49, in convert
    delimiter=delimiter, quotechar=quotechar)
  File "/usr/lib/python2.7/site-packages/unicodecsv/py2.py", line 110, in __init__
    self.reader = csv.reader(f, dialect, **kwds)
TypeError: "delimiter" must be an 1-character string

This also happens with Python 3.6.1.

Preserve row order of input file?

Thanks for csvtotable! It works great except for one (minor) issue. The rows of my input files are sorted in a specific order but csvtotable appears to automatically (re)sort the data on the first column when generating the html table. Not a huge deal, but it would be nice to have the option to preserve the row order of the input file. Again, thanks for csvtotable!

is this repo still alive?

Why there are so many unresolved issues and unmerged PRs? If you can give me write access I can help you develop this repo.

Change names and colours

Really nice program. Is there a way to add names to the column 1 to column n to something else, please?
ideally i would like to have column 1 is name, column 2 is date, column n to be measurements x. Also, any way to add my own text at the top and at bottom of the page, please?

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.