How to get column names and values from Google Sheets in Python Code node n8n?

Welcome @Quent to our community! I’m Jay and I am a n8n verified creator.

In n8n’s Python Code node, the variable is items (not _input). Each item in items is a dict with a json key. Here’s the corrected version:

for item in items:
    row = item["json"]
    for column_name, value in row.items():
        print(f"Column: {column_name}")
        print(f"Value: {value}")

return items

Note: you also need to return items at the end of the Code node or it will return nothing downstream.