source: python/aubio/txtfile.py @ 220dcfc

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

import 0.1.7.1

  • Property mode set to 100644
File size: 1.4 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 Paul Brossier <piem@altern.org>
7
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21"""           
22
23def read_datafile(filename,depth=-1):
24    """read list data from a text file (columns of float)"""
25    fres = open(filename,'ro')
26    l = []
27    while 1:
28        tmp = fres.readline()
29        if not tmp : break
30        else: tmp = tmp.split()
31        if depth > 0:
32            for i in range(min(depth,len(tmp))):
33                tmp[i] = float(tmp[i])
34            l.append(tmp)
35        elif depth == 0:
36            l.append(float(tmp[0]))
37        else:
38            for i in range(len(tmp)):
39                tmp[i] = float(tmp[i])
40            l.append(tmp)
41    return l
42
Note: See TracBrowser for help on using the repository browser.