Selection Overview¶
Here you will find an overview of psv’s objects and methods, but not the objects attributes which are generated dynamically by psv.
Api¶
Selections¶
- class
psv.core.objects.selections.Selection(selection, api_mother)¶
addcolumn¶Adds a column :param columnname: Name of the column to add. :param columndata: The default value of the new column. :param add_to_columns: Determines whether this column should
be added to the internal tracker.
- Note: Rows that are being accessed by another thread will error out
- if accessed during the brief time addcolumn is updating.
- Note: This will affect the entire MainSelection, not just this
- selection
all_output()¶Sets all rows to output
any(selectionfirstarg_data=None, **kwargs)¶Method for selecting part of the csv document. generates a function based of the parameters given. only one condition must be True for the row to be
selected.Uses Lazy Loading, doesn’t process till needed.
columns¶
columns_attributes¶
columns_mapping¶
delcolumn¶
disable(selectionfirstarg_data=None, **kwargs)¶
enable(selectionfirstarg_data=None, **kwargs)¶
find(selectionfirstarg_data=None, **kwargs)¶
find_all(selectionfirstarg_data=None, **kwargs)¶
find_all_any(selectionfirstarg_data=None, **kwargs)¶
find_any(selectionfirstarg_data=None, **kwargs)¶
flip(selectionfirstarg_data=None, **kwargs)¶
flip_output()¶flips all output boolean for all rows in this selection
grab(*args)¶Grabs specified columns from every row
Returns: tupleof the result.
len_no_output()¶
lenoutput()¶
merge(*args, force_safety=True)¶Merges selections
- Note: This merge’s algorithm relies on the uniqueness of the rows.
- duplicate rows will be only represented by 1 row.
Note: This Merge relies on all data in a row being hashable, use non_hash_merge if you can’t guarantee this.
no_output()¶Sets all rows to not output
non_hash_merge(*args)¶This merge uses the exploits the __output__ flag of a row instead of it’s hashed contents This allows merging of of rows that contain unhashable mutable data such as sets or dict. This doesn’t remove duplicate rows but is slightly faster and can handle all datatyps.
- Note: This merge is effectively single-threaded and editing the outputflag during
- running will effect results of the merge and may have unattended conquences on the state of this selection.
nonoutputtedrows¶
output(f=None, columns=None, quote_all=None, encoding='utf-8')¶
outputs(columns=None, quote_all=None, encoding='utf-8')¶Outputs to str
outputtedrows¶
process()¶Processes the Selection, then returns it
- Use this if chaining selections but you still need the parent
- for later usage. Or if their are mulitple chains from the same parent selection
remove_duplicates(soft=True)¶Removes duplicates rows if soft is true, return a selection else: edit this object
Note: All rows must contain hashable data
rows¶
safe_any(selectionfirstarg_data=None, **kwargs)¶Method for selecting part of the csv document. generates a function based off the parameters given. only one condition must be True for the row to be selected.
- This instantly processes the select instead of
- lazily loading it at a later time. Preventing race conditions under most uses cases. if the same select is being worked on in multiple threads or other cases such as rows being edited before the selected is processed.
safe_merge(*args)¶This is much slower but is hashes rows as processed instead of preprocessing them
safe_select(selectionfirstarg_data=None, **kwargs)¶Method for selecting part of the csv document. generates a function based off the parameters given.
- This instantly processes the select instead of
- lazily loading it at a later time. Preventing race conditions under most uses cases. if the same select is being worked on in multiple threads or other cases such as rows being edited before the selected is processed.
select(selectionfirstarg_data=None, **kwargs)¶Method for selecting part of the csv document. generates a function based of the parameters given. All conditions must be true for a row to be selected Uses Lazy Loading, doesn’t process till needed.
single_find(selectionfirstarg_data=None, **kwargs)¶Find a single row based off search criteria given. will raise error if returns more than one result
single_find_any(selectionfirstarg_data=None, **kwargs)¶Find a single row based off search criteria given. Only condition needs to be Trues. will raise error if returns more than one result
tabulate(limit=100, format='grid', only_ascii=True, columns=None, text_limit=None, remove_newline=True)¶
transform(column, func)¶
unique(*args)¶Grabs specified columns from every row
Returns: setof the result.