-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow defining field names that don't follow the restrictions of python variables #3266
Comments
If you're using dicts instead of scrapy.Item instances, you can do But I like the idea, I think we can it built-in. |
I like that idea, but, wouldn't it be possible to reference the Item or the Item Loader by both the export_name or the var name instead of adding a new pipeline? For example:
|
#3696 also should solve this, though in a slightly different way. |
Is there any PR to provide this by default as for now? The "export_name" suggestion from @dyeray sounds like the perfect deal. |
Regarding |
itemadapter already supports field metadata. So we may only need to modify Scrapy to check the metadata, and if there is an Shall we create a new issue about it, and maybe target 2.7? |
Sometimes we may require defining field names that are not valid Python variables (for example containing spaces). I believe the correct way of doing this right now is that the developer needs to add a Pipeline that maps the internal name to the name we wan't to export. Scrapy could ship with a Pipeline (maybe enabled by default) that does this mapping for fields that define a field parameter. For example:
This is a very simple pipeline. However, since this is a very common use case, I think it is something that could be shipped by default. I'm happy to provide a PR for this.
The text was updated successfully, but these errors were encountered: