read_file
phyllotaxis_analysis.read_file Link
This module contains a class and some functions to read and extract data from a csv file. We suppose that the data for each plant is stored in a column.
read_csv_file Link
read_csv_file(filename)
Read and extract divergence angles from a tab-separated CSV file.
This function reads a CSV file where each plant's data is stored in a column, converts valid integer values to integers, and returns them as nested lists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
Path to the CSV file to be read. The file must use tab characters as delimiters. |
required |
Returns:
Type | Description |
---|---|
list of list of int
|
A nested list where each sublist contains integer values extracted from the CSV file. Returns an empty list if the file is not found or contains non-integer values. |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the specified file does not exist. |
ValueError
|
If the file contains non-integer values that cannot be converted. |
Source code in src/phyllotaxis_analysis/read_file.py
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
read_seq_file Link
read_seq_file(filename)
Read and extract data from a .seq file
Parameters: filename (str): file name to read
Returns: list: list of sequences of divergence angles
Raises: FileNotFoundError: If the file does not exist IOError: If there's an error reading the file
Source code in src/phyllotaxis_analysis/read_file.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
read_txt_data_file Link
read_txt_data_file(filename)
Reads a text data file containing angles represented by integer values and returns a list of lists with those values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
The path to the text file that will be read, including its name and file extension (e.g., 'path/to/file.txt'). |
required |
Returns:
Name | Type | Description |
---|---|---|
angles_list |
list
|
A list of lists where each inner list contains three integer values representing angles in a line of the input text file. If there are any issues reading or parsing the file, an empty list will be returned. |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the specified file does not exist. |
ValueError
|
If the file contains non-integer values that cannot be converted. |
Source code in src/phyllotaxis_analysis/read_file.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|