Skip to content
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

I/O from file descriptors #57

Open
awicenec opened this issue Feb 15, 2013 · 8 comments
Open

I/O from file descriptors #57

awicenec opened this issue Feb 15, 2013 · 8 comments
Milestone

Comments

@awicenec
Copy link

It would be very helpful to add support for reading and writing from and to standard file descriptors, rather than just named files. That would allow reading and writing from/to sockets and strings using stringIO.

@ebressert
Copy link
Member

That's a great point. Is the file descriptor you have in mind specific to ASCII, binary, or some other format? Or more general? For ASCII you could piggy back on Asciitables, which is what the ASCII parsing in ATpy depends on. Let us know and we'll try to make the feature available.

@astrofrog
Copy link
Member

By the way, this should already be possible with some of the formats - which format did you (unsuccessfully) try?

@awicenec
Copy link
Author

Hi Thomas,

well, I actually did not try, but more or less relied on the documentation saying what has to be provided needs to be a filename (string). Anyway if this is something you are considering, I think the behaviour should be the same for all formats.

Cheers,
Andreas

On 16/02/2013, at 6:49 PM, Thomas Robitaille notifications@github.com wrote:

By the way, this should already be possible with some of the formats - which format did you (unsuccessfully) try?


Reply to this email directly or view it on GitHub.

@astrofrog
Copy link
Member

@awicenec - looking at the code, it seems reading from file objects is supported for all formats, but writing to file objects is not, so I'll see if this can be added.

@steven-murray
Copy link

I would very much like to see this implemented as well. Which of the formats already support it if you don't mind me asking? I would need to write to stringIO file-like objects so that they can be used as response objects in django...

@astrofrog
Copy link
Member

@steven-murray - which format do you need to be able to write to? The reason I ask is because Astropy already supports writing to VO tables, ASCII tables, and HDF5 in version 0.2, and I'm pretty sure it allows writing to file objects:

http://docs.astropy.org/en/stable/table/index.html

If you need FITS output, that will appear in version 0.3 (and is already available in the developer version of Astropy).

We are recommending users transition to using Astropy when possible, so let me know if that works for you.

@steven-murray
Copy link

Sorry I didn't see this reply!

I was hoping to output to both ASCII and HDF5, so if they are both supported already that's great! I'll have to look into this again :)

Cheers,
Steven

@astrofrog
Copy link
Member

Both these formats are supported by astropy.table so I'd recommend using that if at all possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants