Skip to content

Instantly share code, notes, and snippets.

@eupendra
Created August 31, 2022 10:43
Show Gist options
  • Save eupendra/e84d54ae01c9b224ad1e1cccd91af77f to your computer and use it in GitHub Desktop.
Save eupendra/e84d54ae01c9b224ad1e1cccd91af77f to your computer and use it in GitHub Desktop.
def process_item(self, item, spider):
adapter = ItemAdapter(item)
d = adapter.asdict()
if self.current_row_index == 0: # Write Header
fmt = self.heading_format
for column, value in enumerate(d.keys()):
self.worksheet.write(self.current_row_index, column, value, fmt)
data = d.values()
fmt = self.cell_format
for column, value in enumerate(data):
self.worksheet.write(self.current_row_index+1, column, value, fmt)
self.current_row_index += 1
return item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment