Giter Site home page Giter Site logo

loadtxt and savetxt about stdlib HOT 10 CLOSED

fortran-lang avatar fortran-lang commented on May 25, 2024 2
loadtxt and savetxt

from stdlib.

Comments (10)

jvdp1 avatar jvdp1 commented on May 25, 2024 1

@certik Nice examples. I think it could be easily combine with something like

real, allocatable :: a(:)
type(File) :: f
f = File('log.txt')
call f%read(a)
call f%close()

Float, double-precision,integer,... could be then supported.

from stdlib.

milancurcic avatar milancurcic commented on May 25, 2024

I think these are great functions to start with and figure out the workflow. Good to go ahead as far as I'm concerened.

What module would this belong to? stdlib_io in io.f90?

from stdlib.

certik avatar certik commented on May 25, 2024

I think we agreed to prefix modules with stdlib_.

The io module (stdlib_io.f90) might be a good name for it. NumPy has this directly in the numpy namespace, but I think we should have things in modules, not the global stdlib namespace. Because we can always later expose some frequently used functionality in stdlib.f90 directly, but if we put it there now, it will be hard to remove later, as it would break people's code.

There is also scipy.io, with loadmat that loads Matlab's file.

So stdlib_io.f90 works.

from stdlib.

milancurcic avatar milancurcic commented on May 25, 2024

@certik Correct, I just re-read #9. module stdlib_io in stdlib_io.f90 is good.

from stdlib.

milancurcic avatar milancurcic commented on May 25, 2024

@jvdp1 Indeed, plain savetxt and loadtxt will be useful on their own, and the File derived type (a higher level abstraction) can later figure out if and how to use these more basic building blocks.

from stdlib.

certik avatar certik commented on May 25, 2024

I sent a PR in #23.

from stdlib.

jacobwilliams avatar jacobwilliams commented on May 25, 2024

We can also get some inspiration from this csv read/write one of mine: https://github.com/jacobwilliams/fortran-csv-module

from stdlib.

certik avatar certik commented on May 25, 2024

@jacobwilliams good point, I created a standalone issue #24 for CSV. You are right that it is related, as in NumPy one can use genfromtxt to read CSV.

from stdlib.

epagone avatar epagone commented on May 25, 2024

Very nice start. What do you think of adding some optional functionalities like the following?

  • Header handling (we might need to define a "comment" character that introduces the header):
    • when reading simply detect it and store it somewhere;
    • when writing add it and number the columns automatically (very useful for writing plotting scripts).
  • column sorting or indexing using, for example, ODERPACK (if there is no licence clash).

I found very useful (actually necessary) both them but I don't know how much general interest there is.

from stdlib.

certik avatar certik commented on May 25, 2024

@epagone, yes, we can add the header, footer, comments, newline, delimiter arguments for savetxt that NumPy has. We can also do the fmt argument and pass in Fortran formatting string.

All these arguments go after the fname and X arguments, so I think we can add them in subsequent PRs after #23 is merged.

Can you elaborate on the column sorting or indexing using? I don't think NumPy does that. What prevents the user to sort the data before calling savetxt?

from stdlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.