-
Notifications
You must be signed in to change notification settings - Fork 182
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
io: getfile
#939
io: getfile
#939
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @perazz. LGTM!
I am not a fan of the Camel case, but it is just a matter of taste.
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
My suggestion is this is a better fit as a subroutine. I wouldn't expect anyone to use this in line with other operations. Also a subroutine is easier to extend to other data types in the future if desired. (Since the output argument and type is provided) |
|
Well, while @perazz is making changes, any chance we could add a "notabs" type option? My organization loves to sprinkle tabs into text files, which often wrecks havoc downstream. |
@chuckyvt the string module has a replace_all function that I believe could be a better way to handle that? As we load the whole file at once, there's no way to replace tabs with spaces withouth additional allocations anyway, so it makes sense to call a second function I guess? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @perazz for this contribution. Just a style comment, as @jvdp1 mentioned camel case is not recommended in the stdlib guidelines, actually here https://github.com/fortran-lang/stdlib/blob/HEAD/STYLE_GUIDE.md#variable-and-procedure-naming is mentioned that snake_case
should be prefered. If possible, I would suggest applying it to the naming of the procedures get_file
instead of getfile
and so on.
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Co-authored-by: jalvesz <[email protected]>
Thank you for the edits @jalvesz - regarding the function name, I think it would not be a good idea to have |
I would be in favor of this, considering that the interfaces are still tagged as Out of curiosity I asked chatgpt: https://chatgpt.com/share/67bdeee7-a7dc-800f-bf12-6d9bf8774486 it looks feasible... there are many errors but the raw idea seems to hold, and the key point about "pre-commit" seems to be indeed available, maybe the tooling proposed by Codee could help? https://fortran-lang.discourse.group/t/webinar-enforcing-fortran-coding-guidelines-with-codee/9179 |
I agree with @jalvesz; As it is in
For my private projects in gitlab, I use |
This PR is spun off #904 for discussion with #919.
The present option provides a
getfile
function that has a similar functionality as the existinggetline
from thestdlib_io
module:stdlib_io
type(string_type) function getfile(fileName [,err] [,delete])
loads a whole ASCII file into astring_type
variable all at once, with option to return a state flag, or to request file deletion (delete=.true.
) after loading.The file is loaded all at once for maximum computational efficiency.
The new
state_type
error handler is optionally used to provide clear error information. Its optional as commonly done in linear algebra routines: if provided, an error message may be returned; if not provided, exceptions trigger anerror stop
cc: @jvdp1 @chuckyvt @jalvesz @fortran-lang/stdlib