File: _csv_reader_android.py

package info (click to toggle)
python-expyriment 0.7.0%2Bgit34-g55a4e7e-3.2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,504 kB
  • ctags: 2,094
  • sloc: python: 12,766; makefile: 150
file content (35 lines) | stat: -rw-r--r-- 844 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""An emulation of the csv.reader module.

"""

__author__ = 'Florian Krause <florian@expyriment.org>, \
Oliver Lindemann <oliver@expyriment.org>'
__version__ = '0.7.0'
__revision__ = '55a4e7e'
__date__ = 'Wed Mar 26 14:33:37 2014 +0100'


def reader(the_file):
    '''
    This is a 'dirty' emulation of the csv.reader module only used for 
    Expyriment loading designs under Android. The function reads in a csv file
    and returns a 2 dimensional array.
    
    Parameters
    ----------
    the_file: iterable
        The file to be parsed.
    
    Notes
    -----
    It is strongly suggested the use, if possible, the csv package from the 
    Python standard library.
   
    
    '''
    delimiter = ","
    rtn = []
    for row in the_file:
        rtn.append(map(lambda strn: strn.strip(), row.split(delimiter)))
    return rtn