Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrapy 1.0+ proper settings access in CsvItemExporter subclass?

Previously, accessing settings in a subclass of CsvItemExporter, which I need to modify the delimiter specified in the settings, could be done using:

from scrapy.conf import settings

However that method is now depreciated:

ScrapyDeprecationWarning: Module scrapy.conf is deprecated, use crawler.settings attribute instead from scrapy.conf import settings

How can I do it now? The usual from_crawler, "from_settings class methods don't work in CsvItemExporter.

like image 585
jayshilling Avatar asked Oct 02 '15 16:10

jayshilling


1 Answers

There is currently no way to extend feed exporters with additional parameters. In fact, a feature request exists asking for it: [Enhancement] Allow BaseItemExporter to accept arguments #973

There are also 2 feature requests about allowing to customize the CSV delimiter:

  • CsvItemExporter delimiter should be changeable through settings.py #3252

  • Adding delimiter, quotechar, encoding, lineterminator options to the CSV exporter #3486

So, I suggest you track those requests, consider voting for them (i.e. adding a thumbs up reaction) or providing feedback otherwise, and in the meantime you can either ignore the warning, supress it, or go with nyov’s approach.

like image 192
Gallaecio Avatar answered Oct 05 '22 05:10

Gallaecio