![]() |
Baby Language Lab Scripts
A collection of data processing tools.
|
This class parses information from an ADEX-exported csv file, for use in the Reliability2 program. More...
Public Member Functions | |
def | __init__ |
Constructor. More... | |
def | close |
This method closes the file that the parser is reading. More... | |
def | parse |
Reads the csv file and organizes the information according to environment, activity, and used/unused. More... | |
def | get_acts_list |
Provides a list of all unique activities in the file. More... | |
def | get_envs_list |
Provides a list of all unique environments in the file. More... | |
def | locate_wavfile |
Attempts to locate a particular wav file in a given folder hierarchy. More... | |
def | pick_rows |
Picks a set of blocks from the csv file, for a given check2 object. More... | |
def | have_enough_blocks |
Checks to see if we have enough blocks in a csv file to satisfy the requirements for a given Check2 object. More... | |
Static Public Member Functions | |
def | get_row_timestamp |
Returns a timestamp string that uniquely identifies a row. More... | |
def | get_child_code |
Returns the child code for a give row. More... | |
Public Attributes | |
csv_file | |
reader | |
envs | |
acts | |
parse_dict | |
This class parses information from an ADEX-exported csv file, for use in the Reliability2 program.
It provides tools to obtain a list of the possible activity and environment categories present in the file, and to pick a given number of segments that belong to a specific environment-activity group. The csv file this class operates upon should contain the usual ADEX columns (but with one 5 minute block per row rather than one segment per row - you can set this up using an option in ADEX), in addition to two columns called "Activity" and "environment". Environment is the type of daycare in which the recording took place (eg. "home", "home daycare", or "daycare centre"). This generally stays the same for all 5 minute blocks in a csv file (though it need not). Activity is something the child is engaged in like "mealtime", "playtime - organized", "naptime", etc., and often differs every couple of blocks (depending on the attention span of the child :)
Definition at line 21 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.__init__ | ( | self, | |
filename | |||
) |
Constructor.
self | |
filename | (string) path to the csv file to read. |
Definition at line 25 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.close | ( | self | ) |
This method closes the file that the parser is reading.
It should always be called when you are done with a parser instance.
self |
Definition at line 46 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.get_acts_list | ( | self | ) |
Provides a list of all unique activities in the file.
self |
Definition at line 100 of file reliability2_parser.py.
|
static |
Returns the child code for a give row.
row | (list) the row of the csv file from which to extract the child code |
Definition at line 204 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.get_envs_list | ( | self | ) |
Provides a list of all unique environments in the file.
self |
Definition at line 106 of file reliability2_parser.py.
|
static |
Returns a timestamp string that uniquely identifies a row.
row | (list) the row of the csv file for which to generate a timestamp string |
row_offset_sec | (float) the absolute start time of the row. You cannot use the "Elapsed_Time" column value for this - it may restart several times in the same file. Instead, you should use an accumulator variable that calculates the absolute start time of each row as you loop through the csv file. See parse() for an example. |
Definition at line 193 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.have_enough_blocks | ( | self, | |
check2, | |||
include_used | |||
) |
Checks to see if we have enough blocks in a csv file to satisfy the requirements for a given Check2 object.
The check2 object has properties that tell the parser which environment-activitiy categories to pick from, and how many blocks to pick for each.
self | |
check2 | (Check2) the Check2 instance for which we are counting blocks. |
include_used | (boolean) By default, this method only counts blocks from the parser's 'unused' category (see parse()). If this is set to True, then the method assumes that the same block may be picked more than once. |
Definition at line 222 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.locate_wavfile | ( | self, | |
wav_filename, | |||
root_dir | |||
) |
Attempts to locate a particular wav file in a given folder hierarchy.
Returns the path if it's found.
self | |
wav_filename | (string) the name of the wav file to search for (this should not contain any path information - just the bare filename, eg. "C001a_20090708.wav") |
root_dir | (string) the full path to the root directory of the folder hierarchy to search for the wav file |
Definition at line 114 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.parse | ( | self | ) |
Reads the csv file and organizes the information according to environment, activity, and used/unused.
The info is placed into the organized parse_dict dictionary described in the constructor.
self |
Definition at line 52 of file reliability2_parser.py.
def parsers.reliability2_parser.Reliability2Parser.pick_rows | ( | self, | |
check2, | |||
alt_wav_locate_fcn, | |||
include_used | |||
) |
Picks a set of blocks from the csv file, for a given check2 object.
The check2 object has properties that tell the parser which environment-activitiy categories to pick from, and how many blocks to pick for each. It is possible that there are not enough blocks of a particular category in the csv file. You can check this before calling this method, by calling the have_enough_blocks() method. If there are not enough blocks of a given type, and this method is still called anyway, it will return as many blocks as exist for each requested category.
self | |
check2 | (Check2) the Check2 instance for which we are picking blocks. |
alt_wav_locate_fcn | (function) allows you to specify a custom search function that returns the path to the wav file, if the default locator method in this class (locate_wavfile()) cannot find it. This param was added to allow calling code to pass in a function that opens a "browse file" dialog box, so that the user can select the file manually if the code can't find it. The function is passed the name of the wav file we are looking for. If this custom search function also fails to return a path, an exception is raised. |
include_used | (boolean) By default, this method only picks blocks from the parser's 'unused' category (see parse()). If this is set to True, then the same block may be picked more than once. |
Definition at line 151 of file reliability2_parser.py.
parsers.reliability2_parser.Reliability2Parser.acts |
Definition at line 33 of file reliability2_parser.py.
parsers.reliability2_parser.Reliability2Parser.csv_file |
Definition at line 26 of file reliability2_parser.py.
parsers.reliability2_parser.Reliability2Parser.envs |
Definition at line 30 of file reliability2_parser.py.
parsers.reliability2_parser.Reliability2Parser.parse_dict |
Definition at line 40 of file reliability2_parser.py.
parsers.reliability2_parser.Reliability2Parser.reader |
Definition at line 27 of file reliability2_parser.py.