Ejemplo n.º 1
0
def remove(table, id_):
    """
    Remove a record with a given id from the table.

    Args:
        table (list): table to remove a record from
        id_ (str): id of a record to be removed

    Returns:
        list: Table without specified record.
    """

    table = data_manager.get_table_from_file("sales/sales.csv")
    index_to_remove = common.index_list_of_list(id_, table)
    table.remove(table[index_to_remove])
    data_manager.write_table_to_file("sales/sales.csv", table)
    start_module()

    return table
Ejemplo n.º 2
0
def update(table, id_):
    """
    Updates specified record in the table. Ask users for new data.

    Args:
        table (list): list in which record should be updated
        id_ (str): id of a record to update

    Returns:
        list: table with updated record
    """

    table = data_manager.get_table_from_file("crm/customers.csv")
    id_ = id_[0]
    update_data = ui.get_inputs(["Name: ", "E-mail: ", "Subscribed: "], "Please provide data you would like to update:")
    index_to_update = common.index_list_of_list(id_, table)
    update_data.insert(0, id_)
    table[index_to_update] = update_data
    data_manager.write_table_to_file("crm/customers.csv", table)
    start_module()

    return table
Ejemplo n.º 3
0
def update(table, id_):
    """
    Updates specified record in the table. Ask users for new data.

    Args:
        table: list in which record should be updated
        id_ (str): id of a record to update

    Returns:
        list: table with updated record
    """
    table = data_manager.get_table_from_file("store/games.csv")
    id_ = id_[0]
    update_data = ui.get_inputs(
        ["Title: ", "Manufacturer: ", "Price :", "In_stock: "],
        "Please provide data you would like to update:")
    index_to_update = common.index_list_of_list(id_, table)
    update_data.insert(0, id_)
    table[index_to_update] = update_data
    data_manager.write_table_to_file("store/games.csv", table)
    start_module()

    return table
Ejemplo n.º 4
0
def update(table, id_):
    """
    Updates specified record in the table. Ask users for new data.

    Args:
        table (list): list in which record should be updated
        id_ (str): id of a record to update

    Returns:
        list: table with updated record
    """

    table = data_manager.get_table_from_file("accounting/items.csv")
    id_ = id_[0]
    update_data = ui.get_inputs(
        ["Month: ", "Day: ", "Year: ", "Type: ", "Amount: "],
        "Please provide data you would like to update:")
    index_to_update = common.index_list_of_list(id_, table)
    update_data.insert(0, id_)
    table[index_to_update] = update_data
    data_manager.write_table_to_file("accounting/items.csv", table)
    start_module()

    return table