source: python.old/aubio/txtfile.py @ b554e41

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since b554e41 was b554e41, checked in by Paul Brossier <piem@piem.org>, 11 years ago

moved out old python interface

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
2print aubio.__LICENSE__ for the terms of use
3"""
4
5__LICENSE__ = """\
6  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
7
8  This file is part of aubio.
9
10  aubio is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14
15  aubio is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
22"""           
23
24def read_datafile(filename,depth=-1):
25    """read list data from a text file (columns of float)"""
26    if filename == '--' or filename == '-':
27        import sys
28        fres = sys.stdin
29    else:
30        fres = open(filename,'ro')
31    l = []
32    while 1:
33        tmp = fres.readline()
34        if not tmp : break
35        else: tmp = tmp.split()
36        if depth > 0:
37            for i in range(min(depth,len(tmp))):
38                tmp[i] = float(tmp[i])
39            l.append(tmp)
40        elif depth == 0:
41            l.append(float(tmp[0]))
42        else:
43            for i in range(len(tmp)):
44                tmp[i] = float(tmp[i])
45            l.append(tmp)
46    return l
47
Note: See TracBrowser for help on using the repository browser.