MCPcopy
hub / github.com/dilshod/xlsx2csv / _range

Method _range

xlsx2csv.py:1022–1046  ·  view source on GitHub ↗
(self, rangeStr)

Source from the content-addressed store, hash-verified

1020 # rangeStr: "A3:C12" or "D5"
1021 # example: for cell in _range("A1:Z12"): print cell
1022 def _range(self, rangeStr):
1023 rng = rangeStr.split(":")
1024 if len(rng) == 1:
1025 yield rangeStr
1026 else:
1027 start = re.match(r"^([A-Z]+)(\d+)$", rng[0])
1028 end = re.match(r"^([A-Z]+)(\d+)$", rng[1])
1029 if not start or not end:
1030 return
1031 startCol = start.group(1)
1032 startRow = int(start.group(2))
1033 endCol = end.group(1)
1034 endRow = int(end.group(2))
1035 col = startCol
1036 while True:
1037 for row in range(startRow, endRow + 1):
1038 yield col + str(row)
1039 if col == endCol:
1040 break
1041 t = 0
1042 for i in col: t = t * 26 + ord(i) - 64
1043 col = ""
1044 while t >= 0:
1045 col = chr(t % 26 + 65) + col
1046 t = t // 26 - 1
1047
1048
1049def convert_recursive(path, sheetid, outfile, kwargs):

Callers 3

set_merge_cellsMethod · 0.95
handleStartElementMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected