#8156: [with code] new function readdata
---------------------------+------------------------------------------------
Reporter: zimmerma | Owner: was
Type: enhancement | Status: new
Priority: minor | Milestone: sage-4.3.2
Component: interfaces | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
---------------------------+------------------------------------------------
I'm missing in Sage a function equivalent to "readdata" in Maple,
which reads a file with one object per line, and convert it to a
list of the given type. Here is a tentative implementation:
{{{
def readdata(f,typ):
fp = open(f,"r")
l = []
while true:
s = fp.readline()
if s == '':
break
l.append(typ(s))
fp.close()
return l
}}}
For example readdata("integers", ZZ) will read a file containing one
integer per line, and convert it to a list of integers. One could
also extend the function to read n objects per line.
If a similar function already exists in Sage, please forgive me.
The function name might be renamed to read_data.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8156>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.