maci.loaddict
loads maci data from a file as dict
loading data from a file
Loads any plain text file that contains formatted maci data that follows the maci language syntax (See language), and returns the attribute names and data as a dictionary representing them as key/value pairs.
maci.loaddict -> dict
Basic Example of loading a file using default positional parameter
data = maci.loaddict('my.data')In this example, we simply load maci formatted data from a file using the loaddict function and pass a string of the filepath to the file as the first argument to the function, and assign the returned dictionary object data to a variable.
Example data inside the file
mydata1 = 'data1'
mydata2 = 2Access the data by their individual and respective key names like you normally would on a dictionary in python.
Example accessing and viewing the data
data['mydata1']
data['mydata2']
print(data['mydata1'])
print(data['mydata2'])parameters & arguments
Describes all parameter functionality and accepted data types
filename: str | Path
First required positional argument. Accepts strings and Path objects
Use this parameter to point to your filepath
attr_name_dedup: bool
Optional parameter. Accepts booleans. Default = True
Use this parameter to enable/disable Attribute Name Deduplication. The default setting is enabled.
This feature protects against having duplicate attribute names loaded from a file. This is helpful if a name has already been defined in the file previously and you do not want it to be overwritten accidentally. This ensures attribute names are unique in your file especially when loading large data sets having thousands of names where it may be hard to keep track. You may disable this feature by setting this parameter to False if you need names to be overwritten, but it is recommended to leave it on and write names uniquely.
Last updated