iode.Identities.print_to_file
- Identities.print_to_file(filepath: str | Path, names: str | List[str] = None, format: str = None)[source]
Print the list identities defined by names to the file filepath using the format format.
Argument format must be in the list: - ‘H’ (HTML file) - ‘M’ (MIF file) - ‘R’ (RTF file) - ‘C’ (CSV file)
If argument format is null (default), the A2M format will be used to print the output.
If the filename does not contain an extension, it is automatically added based on the value of format.
If names is a string, it is considered as a pattern and the function will print all identities matching the pattern. The following characters in pattern have a special meaning:
* : any character sequence, even empty
? : any character (one and only one)
@ : any alphanumerical char [A-Za-z0-9]
& : any non alphanumerical char
| : any alphanumeric character or none at the beginning and end of a string
! : any non-alphanumeric character or none at the beginning and end of a string
`` : escape the next character
If names is None, print all identities of the (subset of the) current database.
- Parameters:
- filepath: str or Path
path to the file to print. If the filename does not contain an extension, it is automatically added based on the value of the format argument.
- names: str or list of str, optional
pattern or list of names of the identities to print. If None, print all identities of the (subset of the) current database. Defaults to None.
- format: str, optional
format of the output file. Possible values are: ‘H’ (HTML file), ‘M’ (MIF file), ‘R’ (RTF file) or ‘C’ (CSV file). Defaults to None meaning that the identities will be dumped in the A2M format.
Examples
>>> from iode import identities, SAMPLE_DATA_DIR >>> output_dir = getfixture('tmp_path') >>> identities.load(f"{SAMPLE_DATA_DIR}/fun.idt") Loading .../fun.idt 48 objects loaded >>> identities.print_to_file(output_dir / "identities.csv", "G*") Printing IODE objects definition to file '...identities.csv'... Printing GAP2 ... Printing GAP_ ... Printing GOSFR ... Print done >>> with open(output_dir / "identities.csv") as f: ... print(f.read()) ... " - GAP2 : 100*(QAFF_/(Q_F + Q_I) )" " - GAP_ : 100*((QAF_/Q_F) -1)" " - GOSFR : GOSF/VAF_"