loadtxt - add `usecols` option
rzehumat opened this issue · 1 comments
rzehumat commented
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.
ivan-pi commented
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?