useful_inkleby.files package

Submodules

useful_inkleby.files.quickgrid module

QuickGrid library - very simple communication with spreadsheets. v1

class useful_inkleby.files.quickgrid.FlexiBook(*args, **kwargs)[source]

Bases: xlwt.Workbook.Workbook

modification to xlwt library - for merging multiple sheets

add_sheet_from_ql(ql)[source]
merge_qls(qls)[source]
class useful_inkleby.files.quickgrid.ItemRow(quick_grid_instance, header_dict, *args, **kwargs)[source]

Bases: list

object returned while iterating through a quick list

class useful_inkleby.files.quickgrid.QuickGrid(name='', header=[], cached=True)[source]

Bases: object

A very simple files interface - loads files into memory so basic reads can be done.

add(row)[source]
add_qg(to_merge)[source]
col_to_location(col)[source]
combine(*args, **kwargs)[source]
count(*columns)[source]
counter(col)[source]
drop(**kwargs)[source]
ensure_column(header_item)[source]

if column doesn’t exist, add it

exclude(col, value)[source]

returns an generator of only rows where col != value

expand(col, seperator=', ')[source]
generate_col(name, generate_function)[source]
get_column(column_id, unique=False)[source]
header_di()[source]

returns a dictionary of ‘safe’ header (striped, lowered) and positions.

include(col, values)[source]

returns an generator of only rows where value in col

iterator_source()[source]
load_from_generator()[source]
classmethod merge(to_merge)[source]

join a bunch of QuickGrids together

only(col, value)[source]

returns an generator of only rows where col = value

open(filename, tab='', header_row=0, force_unicode=False, start=0, limit=None, codec='', **kwargs)[source]

populate from a file

remap(new_header)[source]

return a new quickgrid with a reduced or changed header

rename_column(old_name, new_name)[source]

find old header - replace with enw one

save(filename=None, force_unicode=False)[source]

save out as a csv or xls

sort(*cols)[source]

sort according to columns entered (start with - to reverse)

classmethod split_csv(filename, save_folder, column_id=0, unicode=False)[source]
classmethod split_csv_count(filename, save_folder, limit=1000, force_unicode=False)[source]
split_on_unique(col, col_no=None)[source]
transform(col_name, function)[source]
unique(col)[source]

returns an generator of rows with unique values in col

use_query(query)[source]

use the header to populate with information out of a django query

xls_book()[source]

create xls book from current ql

yield_from_generator()[source]
useful_inkleby.files.quickgrid.export_csv(file, header, body, force_unicode=False)[source]

exports csv (non-unicode)

useful_inkleby.files.quickgrid.import_csv(s_file, unicode=False, start=0, limit=None, codec='')[source]

imports csvs, returns head/body - switch to use different csv processor

useful_inkleby.files.quickgrid.import_xls(s_file, tab='', header_row=0)[source]

does what you’d expect

useful_inkleby.files.quickgrid.import_xlsx(s_file, tab='', header_row=0)[source]

imports xlsx files

useful_inkleby.files.quickgrid.make_safe(v)[source]

useful_inkleby.files.quicktext module

Created on Jul 25, 2016

@author: Alex

class useful_inkleby.files.quicktext.QuickText(text='', filename='')[source]

Bases: object

quick helper object to save as unicode text

conform_quotes()[source]
from_list(ls, delimiter='\r\n')[source]

given a list - merge it

lines(delimiter='\n')[source]

iterate though all lines in the file can amend with .update method

open(**kwargs)
save(**kwargs)

Module contents