matan.files [source]
module matan.files
Classes
-
manager — This class can manage the files as well as it's parameters
-
result — this class is for managing single result file
Functions
-
find_method — Find the technique how the material was created
-
find_modification — function to extract the modification from the filename
-
find_composition — method to obtain material ingridiens from name, as I usually name files extracted from machine with code allowing me to get that information from filename
-
find_comments — function to find the comments in the filename
-
find_number — function to find number of the test
matan.files.manager [source]
class manager()
This class can manage the files as well as it's parameters
This class helps managing he files, find their names/paths, extract the method of manufacturing or other parameters
Methods
-
find — Method to search for the result files
matan.files.manager.find [source]
method manager.find(path, extension: str)
Method to search for the result files
This method allows you to find the files in given path, and returns their result objects.
Parameters
-
path : str — This variable is used to put path to your files
-
extension : str — Extension is the extention of your files. If your file is .csv put csv in there, be aware and do not put the dot before your extension
Examples
FIXME: Add docs.
matan.files.result [source]
class result(path, *args, **kwargs)
this class is for managing single result file
using this class you can extract information like name, modifications, comments, composition etc. It is possible to extract such information from filename. Unfortunately now you need to use strict filename format:
MMETHOD-IIpMATERIAL-IIpMATERIAL[comment].extension
-
first letter is the first letter of your modification list, if the list is empty, then it is omitted,
-
Next letters before "-" sign describing manufacturing method of this result.
-
Next letters after "-" sign are compounds, so first II signs describes percents of the MATERIAL compound, and they are divided by "p" sign.
-
Comments needs to be closed in square brackets. You can play with this class by files module functions given below.
Parameters
-
path : str — This variable is used to put path to your files
Examples
FIXME: Add docs.
matan.files.find_method [source]
function find_method(name: str, delimiter: str = '-', placement: int = 0, *args, **kwargs)
Find the technique how the material was created
Find the method how the material was created, what methods were used to modify it, etc. To do so it is using first letters of filename, so for extruded parts you can use EXT, for annealed extruded parts you can use aEXT etc.
Parameters
-
path : str — path for your file
-
delimiter : str — what sign you wanna use to finish your method string. By default it is -
Examples
FIXME: Add docs.
matan.files.find_modification [source]
staticmethod find_modification(name: str, modifications: list, place: int = 0, *args, **kwargs) → str
function to extract the modification from the filename
Parameters
-
name : str — name of the sample
-
modifications : list — list of possible modification
-
place : int — placement of the first letter of each possible modification
Returns
-
str — Modification name
Raises
-
ValueError — when no modification list is given
Examples
FIXME: Add docs.
matan.files.find_composition [source]
staticmethod find_composition(name: str, delimiter: str = '-', percent_sign='p', *args, **kwargs) → dict
method to obtain material ingridiens from name, as I usually name files extracted from machine with code allowing me to get that information from filename
Parameters
-
name : str — filename to process
-
delimiter : str — delimiter for the composition, default "-"
-
percent_sign —
percent_sign
sign, default "p"
Returns
-
dict — dict of the composition
Examples
import matan as mt
name = "AFDM-10pPET-90pPC_1.csv"
composition = mt.files.find_composition(name,modifications=["Annealing", "Test"])
composition
output: {PET: 10, PC:90}
matan.files.find_comments [source]
function find_comments(name)
function to find the comments in the filename
extract everything in square brackets (hardcoded for now),
Parameters
-
name : str — filename
Returns
-
returns tuple of (comments, cleaned_text) —
cleaned_text
is the filename without comment
Examples
FIXME: Add docs.