Skip to content

Commit

Permalink
Merge pull request #40 from david-salac/feature/nd-exports
Browse files Browse the repository at this point in the history
Fix in to_dict indices
  • Loading branch information
david-salac authored Jan 30, 2021
2 parents 0fca794 + 3c91316 commit 2d5d02b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion portable_spreadsheet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
from .grammar_utils import GrammarUtils # noqa
from .skipped_label import SkippedLabel # noqa

__version__ = "2.1.7"
__version__ = "2.1.8"
__status__ = "Production"
36 changes: 26 additions & 10 deletions portable_spreadsheet/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,49 +604,65 @@ def to_dictionary(self,
x = [label.replace(' ', spaces_replacement)
for label in self.cell_indices.columns_labels[
# Reflects the column offset for export
self.export_offset[1]:self.shape[1]
self.export_offset[1]:(self.export_offset[1] +
self.shape[1])
]
]
if (x_helptext := self.cell_indices.columns_help_text) is not None: # noqa
# Reflects the column offset for export
x_helptext = x_helptext[self.export_offset[1]:self.shape[1]]
x_helptext = x_helptext[
self.export_offset[1]:(self.export_offset[1] +
self.shape[1])
]
x_start_key = 'columns'
# The y-axes represents the rows
y_range = self.shape[0]
y = [label.replace(' ', spaces_replacement)
for label in self.cell_indices.rows_labels[
# Reflects the row offset for export
self.export_offset[0]:self.shape[0]
self.export_offset[0]:(self.export_offset[0] +
self.shape[0])
]
]
if (y_helptext := self.cell_indices.rows_help_text) is not None: # noqa
# Reflects the row offset for export
y_helptext = y_helptext[self.export_offset[0]:self.shape[0]]
y_helptext = y_helptext[
self.export_offset[0]:(self.export_offset[0] +
self.shape[0])
]
y_start_key = 'rows'

# B) The x-axes represents the rows:
if by_row:
x_range = self.shape[0]
x = [label.replace(' ', spaces_replacement)
for label in self.cell_indices.rows_labels[
# Reflects the row offset for export
self.export_offset[0]:self.shape[0]
]
# Reflects the row offset for export
self.export_offset[0]:(self.export_offset[0] +
self.shape[0])
]
]
if (x_helptext := self.cell_indices.rows_help_text) is not None: # noqa
# Reflects the row offset for export
x_helptext = x_helptext[self.export_offset[0]:self.shape[0]]
x_helptext = x_helptext[
self.export_offset[0]:(self.export_offset[0] +
self.shape[0])
]
x_start_key = 'rows'
# The y-axes represents the columns
y_range = self.shape[1]
y = [label.replace(' ', spaces_replacement)
for label in self.cell_indices.columns_labels[
# Reflects the column offset for export
self.export_offset[1]:self.shape[1]
self.export_offset[1]:(self.export_offset[1] +
self.shape[1])
]]
if (y_helptext := self.cell_indices.columns_help_text) is not None: # noqa
# Reflects the column offset for export
y_helptext = y_helptext[self.export_offset[1]:self.shape[1]]
y_helptext = y_helptext[
self.export_offset[1]:(self.export_offset[1] +
self.shape[1])
]
y_start_key = 'columns'

# Export the spreadsheet to the dictionary (that can by JSON-ified)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="portable-spreadsheet",
version="2.1.7",
version="2.1.8",
author="David Salac",
author_email="info@davidsalac.eu",
description="A simple spreadsheet that keeps tracks of each operation of each cell in defined languages. Logic allows exporting sheets to Excel files (and see how each cell is computed), to the JSON strings with a description of computation of each cell (e. g. in the native language). Other formats, like HTML, CSV and Markdown (MD), are also implemented (user can define own format). It also allows reconstructing behaviours in native Python with NumPy.", # noqa
Expand Down

0 comments on commit 2d5d02b

Please sign in to comment.