Skip to content

loadtxt - add usecols option #962

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

Open
rzehumat opened this issue Mar 23, 2025 · 1 comment
Open

loadtxt - add usecols option #962

rzehumat opened this issue Mar 23, 2025 · 1 comment
Labels
idea Proposition of an idea and opening an issue to discuss it

Comments

@rzehumat
Copy link

Motivation

Would it be possible to add an option to skip the loading of certain columns when using the loadtxt from subroutine from stdlib_io?

The use case could be for loading tabular files with missing data. For example, loading a file with the table below would with fmt="*" would fail (unless skiprows=4). However, sometimes one would need just to load columns 1-3.

1.00E+00  2.00E+00  3.00E+00  5.00E+00
4.00E+00  5.00E+00  6.00E+00  5.00E+00
7.00E+00  8.00E+00  9.00E+00  5.00E+00
7.00E+00  8.00E+00  9.00E+00  
7.00E+00  8.00E+00  9.00E+00  5.00E+00
7.00E+00  8.00E+00  9.00E+00  5.00E+00

Prior Art

The option would be similar to usecols option in numpy

Additional Information

Other options to treat missing values are possible -- e.g. supplying NaN to missing values or skipping rows or columns with missing data.

@rzehumat rzehumat added the idea Proposition of an idea and opening an issue to discuss it label Mar 23, 2025
@ivan-pi
Copy link
Member

ivan-pi commented Apr 8, 2025

How would you count columns, if there was a gap?

1.00E+00  2.00E+00  3.00E+00  5.00E+00 3.00E+00
4.00E+00  5.00E+00  6.00E+00  5.00E+00 3.00E+00
7.00E+00  8.00E+00  9.00E+00  5.00E+00 3.00E+00
7.00E+00  8.00E+00  9.00E+00           3.00E+00
7.00E+00  8.00E+00  9.00E+00  5.00E+00 3.00E+00
7.00E+00  8.00E+00  9.00E+00  5.00E+00 3.00E+00

Is the value 3.00E+00 on line 4 part of column 4 or column 5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Proposition of an idea and opening an issue to discuss it
Projects
None yet
Development

No branches or pull requests

2 participants