Giter VIP home page Giter VIP logo

openpyxl-dictreader's People

Contributors

arkhan avatar brocla avatar foprel avatar frankoprel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

openpyxl-dictreader's Issues

Resolve issue with blank lines

Latest PR to implement skipping of blank lines caused unexpected and unstable behaviour. The __next__() method of the DictReader class needs to be restructured to skip blank lines. Possibly give users the options to determine whether to skip blank lines or not by adding a kwarg to the constructor.

openpyxl-dictreader forces use of outdated openpyxl package

In requirements.txt, openpyxl==3.0.3 is a dependency; that's a two-year-old version of openpyxl (current is 3.0.9). Installing openpyxl_dictreader in an environment that also uses openpyxl causes roll-back of openpyxl to that old version.

It appears that openpyxl_dictreader also works with the current version of openpyxl, 3.0.9.

Could requirements.txt please be changed to allow openpyxl==3.0.*, or some other appropriately-large version range?

(It looks like some of the other dependencies in requirements.txt may not be needed, by the way)

"worksheet" should be a required, positional argument to DictReader.__init__

Is there any use-case of DictReader where the default value of None for worksheet does not result in an exception? There always needs to be a worksheet specified. So remove the default value and make it the parameter immediately following filename:

def __init__(self, filename, worksheet, fieldnames=None, restval=None, restkey=None, *args, **kwargs):

btw: I'm finding your module very useful!

setup doesn't work correctly

Your setup.py is not correctly configured for a single module project. You're using a packages keyword in setup() function, but your project doesn't contain any packages.
You should use py_modules=["dictreader"] instead.

Also please consider changing the module name from dictreader to something more specific, for example openpyxl_dictreader, or just pyxl_dictreader. A generic dictreader could conflict with something else (I don't have any examples of conflicting packages at the moment though).

Can't specify keyword arguments to load_workbook

The load_workbook method takes several optional keyword arguments:

  • read_only: optimised for reading, content cannot be edited
  • keep_vba: preserve vba content
  • data_only: controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet
  • keep_links: whether links to external workbooks should be preserved. The default is True

In order to read the values from Excel cells with formulas, data_only needs to be True. Others may be necessary as well.

I suggest passing kwargs (expanded with the ** operator) to load_workbook:

self.wb = load_workbook(filename, **kwargs)

openpyxl.DictWriter

Frank,

Would you be interested in an openpyxl dictionary writer to go with the reader?
The design of the interface would mimic the interface of the csv tool for writing dictionaries, similar to the reader.

dwriter = DictWriter(filename, fieldnames, worksheet="", restval="", extrasaction="raise", write_only=False, iso_dates=False)

restval and extrasaction are arguments from csv.DictWriter().
write_only and iso_dates are arguments from openpyxl's Workbook().

A typical usage would look like:

from openpyxl_dictreader import DictWriter


fieldnames = ["First Name", "Last Name"]

troupe = [
    dict(zip(fieldnames, ["Eric", "Idle"])),
    dict(zip(fieldnames, ["Graham", "Chapman"])),
    dict(zip(fieldnames, ["John", "Cleese"])),
]

dwriter = DictWriter("names.xlsx", fieldnames)
dwriter.writeheader()
for player in troupe:
    dwriter.writerow(player)
dwriter.save()

Incomprehensible behavior with an empty row

Good afternoon. Thanks for the helpful script! I don't understand one piece of code in it:

while row == []:
            row = next(iter(self.ws_list))

Firstly, I cannot imagine in what case the program should be included in this part of the code.

And secondly, I cannot understand where the variable self.ws_list comes from.

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.