Ad
Get File Object Used By A CSV Reader/Writer Object
Is there any way to access the file object used by a CSV writer/reader object after it has been instantiated? I openned up the csv module, and it appears it's contest are builtin. I also tried setting the file object as a property but I get the following error:
AttributeError: '_csv.writer' object has no attribute 'fileobj'
Ad
Answer
csv.writer
is a "builtin" function. That is, it is written in compiled C code rather than Python. So its internal variables can't be accessed from Python code.
That being said, I'm not sure why you would need to inspect the csv.writer object to find out the file object. That object is specified when creating the object:
w = csv.writer(fileobj, dialect, ...)
So if you need to access that object later, just save it in another variable.
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad