import xlwings as xw
wb = xw.Book('trial py algo.xlsx')
sheet = wb.sheets['Sheet2']
for row_no in range(2,13):
print(row_no)
name = sheet['A'+ str(row_no)].value
buy_sell = sheet['B'+ str(row_no)].value
qty = sheet['C'+ str(row_no)].value
print(name,buy_sell)

for row_no in range(2,13):
Traceback (most recent call last):
File "c:\Users\shubh\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 1245, in internal_evaluate_expression_json
pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=True)
File "c:\Users\shubh\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 368, in new_func
return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec)
File "c:\Users\shubh\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 333, in _run_with_unblock_threads
return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec)
File "c:\Users\shubh\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 304, in _run_with_interrupt_thread
return original_func(py_db, frame, expression, is_exec)
File "c:\Users\shubh\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 547, in evaluate_expression
compiled = _compile_as_exec(expression)
File "c:\Users\shubh\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 411, in _compile_as_exec
return compile(expression_to_evaluate, "<string>", "exec", _ASYNC_COMPILE_FLAGS)
File "<string>", line 2
for row_no in range(2,13):
^
SyntaxError: unexpected EOF while parsing
print(row_no)
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'row_no' is not defined
'A'+ str(row_no)
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'row_no' is not defined
'A'+ str(row_no)
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'row_no' is not defined
The code working just fine at my end …
just check sheet2 is there or not in the excel file, which you defined at line no. 8
1 Like
