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

ENH: reading headers and footers using loadtxt #28153

Open
giochanturia opened this issue Jan 14, 2025 · 2 comments
Open

ENH: reading headers and footers using loadtxt #28153

giochanturia opened this issue Jan 14, 2025 · 2 comments

Comments

@giochanturia
Copy link

Proposed new feature or change:

numpy.savetxt has header and footer as parameters. It would be nice to have a reverse functionality while loading the file using numpy.loadtxt.

@Tontonio3
Copy link

Hey, probably it is best to add a function line numpy.loadtxt_with_comments (name can change), that with return the comments (Header and Footer are considered comments) too, so you don't lose them.

@anscian
Copy link

anscian commented Feb 6, 2025

For removing header and footer while loading a file, numpy.genfromtxt can be used instead which provides handling of the comments as well. It isn't fast enough though compared to numpy.loadtxt. For using numpy.loadtxt, skipping header is as straightforward as setting the argument skiprows as the number of lines in header. Handling footers in numpy.loadtxt could be a challenge though.

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

No branches or pull requests

4 participants