<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_index_from_fieldspec(self, table: str, fieldspec: FIELDSPEC_TYPE, indexname: str = None) -> None: """Calls create_index based on a fieldspec, if the fieldspec has indexed = True."""

        if "indexed" in fieldspec and fieldspec["indexed"]:
            if "index_nchar" in fieldspec:
                nchar = fieldspec["index_nchar"]
            else:
                nchar = None
            self.create_index(table, fieldspec["name"], nchar,
                              indexname=indexname)