Created
August 31, 2022 10:43
-
-
Save eupendra/e84d54ae01c9b224ad1e1cccd91af77f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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