GithubHelp home page GithubHelp logo

html2csv's People

Contributors

davidginzberg avatar r-barnes avatar

Stargazers

 avatar

Watchers

 avatar

html2csv's Issues

Remove create/delete behavior when ignoring empty tables

Currently if --ignoreempty is active all tables are still created on disk, but empty tables are subsequently deleted. A better approach (that will also help with providing html2csv as a module) would be to determine which tables will be created before creating them (possibly storing in memory, though this could become an issue for very large pages).

Add an argument to enable/disable table de-nesting

As described in source:

...
    #Removes nested tables. for handling the sins of 1990's web pages.
    #TODO: Add an argument to enable/disable table de-nesting
    [t.extract() for t in table.findAll("table")]
    #This would grab all TRs regardless of depth without the above line removing nested tables
    for row in table.findAll('tr'):
...

The table de-nesting hack is currently default behavior. For better backwards compatibility and flexibility it may be better to make it off-by-default and add a flag to enable it.

Add `-v`/`--verbose`/`-V`/`--very-verbose` options

From source:

...
#TODO: Add a -v/--verbose option for the excessive print statements below. Consider both `-v` `-V` (AKA: VERY VERBOSE, which is currently the default)
...
    for row in table.findAll('tr'):
      print(f"Processing row number {rowcount}")
      rowcount += 1
      cols = row.findAll(['td','th'])
      print(f"Found {len(cols)} columns.")
...

Output during processing is now a little excessive. Some of the output is useful for debugging but should be off by default. Adding verbosity flags gives the user some flexibility here.

Compress multiple rows of sometimes-misaligned headers into one

From source:

...
#TODO: Add option to compress multi-line categorical headers (eg: headers with colspan>1) into concatenated-naming-style single row headers
#  EG: "Population" header spanning above sub-headers "Number" and "Percentage" produces two single-column headers of "Population - Number"
#  and "Population - Percentage". Delemiter can be configurable with a sensible default set.
...

IIRC the CSV spec only allows for one line of headers, so this is also a specification compliance issue.

Detect and discard empty tables

From source:

...
      print(f"Found {len(cols)} columns.")
      #TODO: Detect and discard empty tables (those that contain 1 row, 1 column, consisting of an empty string...I think?)
      #TODO: Add a warning for non-rectangular tables.
      if cols:
        cols = [str(x.text).strip() for x in cols]
...

Currently several of the files generated contain no meaningful content (sometimes the whole file is ""). These tables are likely artifacts of layout tables and can be discarded in most cases. This may be worth acknowledging in verbose output and enabling/disabling via a flag.

Warn if table is not rectangular

from source:

...
      cols = row.findAll(['td','th'])
      print(f"Found {len(cols)} columns.")
      #TODO: Detect and discard empty tables (those that contain 1 row, 1 column, consisting of an empty string...I think?)
      #TODO: Add a warning for non-rectangular tables.
...

Tables with varying numbers of columns per row may be a sign that there are layout tables, errors, or multicolumn headers (not currently supported). Produce a warning when these are seen (and allow it to be disabled or cause script to abort, both based on command flags)

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.