useful_inkleby.files package

QuickGrid Usage

grid = QuickGrid().open(FILEPATH)

for r in grid:
    #for each row
    print r["foo"] #print the value for the column called "foo"

for r in grid.only("city","london"):
    #for each row
    print r["foo"]

for r in grid.exclude("fruit","banana"):
    #for each row
    print r["foo"]

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

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.

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, **kwargs)[source]

populate from a file

remap(new_header)[source]

return a new quickgrid with a reduced or changed header

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]
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)[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]