xlwings-utils 25.0.7__py3-none-any.whl → 25.0.7.post1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xlwings-utils might be problematic. Click here for more details.

@@ -290,6 +290,11 @@ class block:
290
290
  self.number_of_rows = number_of_rows
291
291
  self.number_of_columns = number_of_columns
292
292
 
293
+ def __eq__(self,other):
294
+ if isinstance(other, block):
295
+ return self.value == other.value
296
+ return False
297
+
293
298
  @classmethod
294
299
  def from_value(cls, value, column_like=False):
295
300
  """
@@ -297,18 +302,12 @@ class block:
297
302
 
298
303
  Parameters
299
304
  ----------
300
- value : scaler, list of scalars, list of lists of scalars or block
305
+ value : scalar, list of scalars, list of lists of scalars or block
301
306
  value to be used in block, possibly expanded to a list of lists of scalars
302
307
 
303
308
  column_like : boolean
304
309
  if value is a list of scalars, values is interpreted as a column if True, as a row otherwise
305
310
 
306
- number_of_rows : int
307
- if given, expand or shrink to the given number of rows
308
-
309
- number_of_columns : int
310
- if given, expand or shrink to the given number of columns
311
-
312
311
  Returns
313
312
  -------
314
313
  block : block
@@ -328,7 +327,7 @@ class block:
328
327
  for column, item in enumerate(row_contents, 1):
329
328
  if item and not (isinstance(item, float) and math.isnan(item)):
330
329
  bl.dict[row, column] = item
331
- bl._number_of_columns = max(bl.number_of_columns, column)
330
+ bl._number_of_columns = max(bl.number_of_columns, column)
332
331
  return bl
333
332
 
334
333
  @classmethod
@@ -341,19 +340,12 @@ class block:
341
340
  rng : xlwings.Range
342
341
  range to be used be used in block
343
342
 
344
- number_of_rows : int
345
- if given, expand or shrink to the given number of rows
346
-
347
- number_of_columns : int
348
- if given, expand or shrink to the given number of columns
349
-
350
343
  Returns
351
344
  -------
352
345
  block : block
353
346
  """
354
347
  number_of_rows, number_of_columns = rng.shape
355
- bl = cls.from_value(rng.value, column_like=(number_of_columns == 1))
356
- return bl
348
+ return cls.from_value(rng.value, column_like=(number_of_columns == 1))
357
349
 
358
350
  @classmethod
359
351
  def from_xlrd_sheet(cls, sheet):
@@ -365,12 +357,6 @@ class block:
365
357
  sheet : xlrd sheet
366
358
  sheet to be used be used in block
367
359
 
368
- number_of_rows : int
369
- if given, expand or shrink to the given number of rows
370
-
371
- number_of_columns : int
372
- if given, expand or shrink to the given number of columns
373
-
374
360
  Returns
375
361
  -------
376
362
  block : block
@@ -380,6 +366,18 @@ class block:
380
366
 
381
367
  @classmethod
382
368
  def from_openpyxl_sheet(cls, sheet):
369
+ """
370
+ makes a block from an openpyxl sheet
371
+
372
+ Parameters
373
+ ----------
374
+ sheet : xlrd sheet
375
+ sheet to be used be used in block
376
+
377
+ Returns
378
+ -------
379
+ block : block
380
+ """
383
381
  v = [[cell.value for cell in row] for row in sheet.iter_rows()]
384
382
  return cls.from_value(v)
385
383
 
@@ -393,12 +391,6 @@ class block:
393
391
  filename : str
394
392
  file to be used be used in block
395
393
 
396
- number_of_rows : int
397
- if given, expand or shrink to the given number of rows
398
-
399
- number_of_columns : int
400
- if given, expand or shrink to the given number of columns
401
-
402
394
  Returns
403
395
  -------
404
396
  block : block
@@ -417,12 +409,6 @@ class block:
417
409
  df : pandas dataframe
418
410
  dataframe to be used be used in block
419
411
 
420
- number_of_rows : int
421
- if given, expand or shrink to the given number of rows
422
-
423
- number_of_columns : int
424
- if given, expand or shrink to the given number of columns
425
-
426
412
  Returns
427
413
  -------
428
414
  block : block
@@ -432,18 +418,12 @@ class block:
432
418
 
433
419
  def to_openpyxl_sheet(self, sheet):
434
420
  """
435
- makes a block from a given openpyxl sheet
421
+ appends a block to a given openpyxl sheet
436
422
 
437
423
  Parameters
438
424
  ----------
439
425
  sheet: openpyxl sheet
440
- sheet to be used be used in block
441
-
442
- number_of_rows : int
443
- if given, expand or shrink to the given number of rows
444
-
445
- number_of_columns : int
446
- if given, expand or shrink to the given number of columns
426
+ sheet to be used be used
447
427
 
448
428
  Returns
449
429
  -------
@@ -474,8 +454,8 @@ class block:
474
454
  number_of_columns = self.number_of_columns
475
455
  bl = block(number_of_rows=number_of_rows, number_of_columns=number_of_columns)
476
456
  for (row, column), value in self.dict.items():
477
- if row <= number_of_columns and column <= number_of_columns:
478
- bl.dict[row, column] = value
457
+ if row <= number_of_rows and column <= number_of_columns:
458
+ bl[row, column] = value
479
459
  return bl
480
460
 
481
461
  @property
@@ -488,7 +468,11 @@ class block:
488
468
  raise IndexError(f"row must be between 1 and {self.number_of_rows} not {row}")
489
469
  if column < 1 or column > self.number_of_columns:
490
470
  raise IndexError(f"column must be between 1 and {self.number_of_columns} not {column}")
491
- self.dict[row, column] = value
471
+ if value is None:
472
+ if (row,column) in self.dict:
473
+ del self.dict[row,column]
474
+ else:
475
+ self.dict[row, column] = value
492
476
 
493
477
  def __getitem__(self, row_column):
494
478
  row, column = row_column
@@ -562,7 +546,7 @@ class block:
562
546
  if column > self.number_of_columns:
563
547
  raise ValueError(f"{name}={column} > number_of_columns={self.number_of_columns}")
564
548
 
565
- def transpose(self):
549
+ def transposed(self):
566
550
  """
567
551
  transpose block
568
552
 
@@ -827,7 +811,16 @@ class block:
827
811
 
828
812
  def decode_to_files(self):
829
813
  """
830
- decode the block with encoded file(s) to individual pyoidide files
814
+ decode the block with encoded file(s) to individual pyoidide file(s)
815
+
816
+ Returns
817
+ -------
818
+ count : int
819
+ number of files decoded
820
+
821
+ Note
822
+ ----
823
+ if the block does not contain an encode file, the method just returns 0
831
824
  """
832
825
  count = 0
833
826
  for column in range(1, self.number_of_columns + 1):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xlwings_utils
3
- Version: 25.0.7
3
+ Version: 25.0.7.post1
4
4
  Summary: xlwings_utils
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/salabim/xlwings_utils
@@ -0,0 +1,6 @@
1
+ xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
2
+ xlwings_utils/xlwings_utils.py,sha256=6uy2FTJH96N6I5LNzY_ZRMmCU239v6hdD9wEvtapeIU,28199
3
+ xlwings_utils-25.0.7.post1.dist-info/METADATA,sha256=o94CnW04WADOZdVqgikjP9EqLWXKpOTveMKJER2UnNg,12424
4
+ xlwings_utils-25.0.7.post1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ xlwings_utils-25.0.7.post1.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
6
+ xlwings_utils-25.0.7.post1.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
2
- xlwings_utils/xlwings_utils.py,sha256=e8Lo40ceG0kSzSuytOpIT3cvJ_bhZRxLC2x69EE6k9Y,28725
3
- xlwings_utils-25.0.7.dist-info/METADATA,sha256=NVLthhuk58Inh4nNVC9Bvue1VEUXuRUYdjJYKlhEqyA,12418
4
- xlwings_utils-25.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- xlwings_utils-25.0.7.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
6
- xlwings_utils-25.0.7.dist-info/RECORD,,