Write mode for topen
See original GitHub issueOverview
It’s a long shot but eventually I suppose it could be implemented.
Having a task to write some tabular data to the filesystem is casual. With all the boilerplate code to support py2/3, csv verbose interface etc - it’s a little bit annoying.
Analysis
Interface could be:
with topen('table.csv', mode='w') as table:
table.write(data)
Implementation could be:
topen
returnsReadTable
orWriteTable
regarding to themode='r/w'
- for writing there will be new modules like
Formatter
(anti-parser) andWriter
(anti-loader) with the same modular arhictecture for different targets and formats.
So we will be able to have memory lean things like:
with (topen('http://site.com/source.xls') as source,
topen('target.csv', mode='w') as target):
target.write(source)
Or even with something like tcopy
helper:
tcopy(data, 'target.csv')
tcopy('http://site.com/source.xls', 'target.csv')
Tasks
- TBD
- We should support recoding - https://github.com/frictionlessdata/tabulator-py/issues/50
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How to open a file for both reading and writing? - Stack Overflow
'r+' opens the file for both reading and writing. On Windows, 'b' appended to the mode opens the file in binary mode, so...
Read more >How to open a file in read and write mode with Python?
To open files in read/write mode, specify 'w+' as the mode. For example, f = open('my_file.txt', 'w+') file_content = f.read() ...
Read more >fopen() for an existing file in write mode - GeeksforGeeks
In C, fopen() is used to open a file in different modes. To open a file in write mode, “w” is specified. When...
Read more >Python - Read and Write Files - TutorialsTeacher
Opening a file with "w" mode or "a" mode can only be written into and cannot be read from. Similarly "r" mode allows...
Read more >File Handling in Python: Create, Open, Append, Read, Write
Write mode creates a file for writing content and places the pointer at the start. If the file exists, write truncates (clears) any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pwalsh Just lazy example) We use streams here) So it should be memory lean.
After we will finish it my idea to create example like loading 1GB xls from the web and saving it to csv file with memory profiler showing we don’t use memory)
@roll ok, if that is the internal design. In your examples above, would the writing require the file contents to be loaded to memory? The API description looks like yes, but that would be a mistake IMHO.