I am getting an error with only the f-string.
Can I get your thoughts?
Error line:
Phil
Reading the Traceback, I see it looks like a type error due to Openpyxl.
What's the best way to troubleshoot this? Looking in the Openpyxl docs under the base.py, cell_range.py, and/or worksheet.py modules for '_convert' type errors?
This error says,
f-strings are new in 3.7(?) version.
How could I do this loop without an f-string, very simple so a newbie could understand the loop easily?
Thanks,
phil
looking over the base.py source code, I can see the cause of the error. I'm unsure how to fix it with the f-string.
If I understand this, it's looking for a string with the _convert() function which is held within the __set__() function which is called a tthe bottom of the base.py file:
How to continue logical troubleshooting with this code error?
Thanks,
I'm trying
Phil
Okay, I don't know if anyone is still with me, but I'll continue to document my step-by-step for anyone else behind me.
I've looked over the Openpyxl source code for
Specifically, look at the comment on line 706:
How could I adjust my code to loop over my repetitive lines while fulfilling the worksheet module requirements of
Phil
Can I get your thoughts?
Error line:
sheet.merge_cells(f'{pair[0]}:{pair[1]}{i}')Traceback Error:
Traceback (most recent call last): File "C:\Python36x64\lib\site-packages\openpyxl\descriptors\base.py", line 57, in _convert value = expected_type(value) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:/Python36x64/test.py", line 40, in <module> sheet.merge_cells(f'{pair[0]}:{pair[1]}{i}') File "C:\Python36x64\lib\site-packages\openpyxl\worksheet\worksheet.py", line 705, in merge_cells max_col=end_column, max_row=end_row) File "C:\Python36x64\lib\site-packages\openpyxl\worksheet\cell_range.py", line 58, in __init__ self.min_row = min_row File "C:\Python36x64\lib\site-packages\openpyxl\descriptors\base.py", line 107, in __set__ value = _convert(self.expected_type, value) File "C:\Python36x64\lib\site-packages\openpyxl\descriptors\base.py", line 59, in _convert raise TypeError('expected ' + str(expected_type)) TypeError: expected <class 'int'>Thanks,
Phil
Reading the Traceback, I see it looks like a type error due to Openpyxl.
What's the best way to troubleshoot this? Looking in the Openpyxl docs under the base.py, cell_range.py, and/or worksheet.py modules for '_convert' type errors?
This error says,
TypeError: int() argument must be a stringand
TypeError: expected <class 'int'>Confusing!
f-strings are new in 3.7(?) version.
How could I do this loop without an f-string, very simple so a newbie could understand the loop easily?
Thanks,
phil
looking over the base.py source code, I can see the cause of the error. I'm unsure how to fix it with the f-string.
def _convert(expected_type, value): """ Check value is of or can be converted to expected type. """ if not isinstance(value, expected_type): try: value = expected_type(value) except: raise TypeError('expected ' + str(expected_type)) return valueSource code for openpyxl.descriptors.base
If I understand this, it's looking for a string with the _convert() function which is held within the __set__() function which is called a tthe bottom of the base.py file:
super(MatchPattern, self).__set__(instance, value)I've added extra quotes around the f-string, but that failed too.
How to continue logical troubleshooting with this code error?
Thanks,
I'm trying

Phil
Okay, I don't know if anyone is still with me, but I'll continue to document my step-by-step for anyone else behind me.
I've looked over the Openpyxl source code for
- base.py
- cell_range.py
- worksheet.py
Specifically, look at the comment on line 706:
def merge_cells(self, range_string=None, start_row=None, start_column=None, end_row=None, end_column=None): cr = CellRange(range_string=range_string, min_col=start_column, min_row=start_row, max_col=end_column, max_row=end_row) """ Set merge on a cell range. Range is a cell range (e.g. A1:E1) """ self.merged_cells.add(cr.coord) self._clean_merge_range(cr)so I think the f-string code,
sheet.merge_cells(f'{pair[0]}:{pair[1]}{i}'), is not meeting the type function required by this worksheet module.
How could I adjust my code to loop over my repetitive lines while fulfilling the worksheet module requirements of
Range is a cell range (e.g. A1:E1)Thanks,
Phil