I want to add data below the last value of row a. (pygsheet) - pygsheets

sh[9].append(values=[claststr], start='a8')
This code adds a column.
I want to add a value to the next column with the last value of row 'a' or 'b'.

you can use
wks.append_table(["claststr", None, None, None])
Or you can use
wks.update_value( (1,len(wks[0])), "classstr")

Related

Multiple SQLite unique columns as one

Given the following example:
CREATE TABLE shapes(
shape_id INTEGER PRIMARY KEY,
background_color TEXT,
foreground_color TEXT,
UNIQUE(background_color,foreground_color)
);
background_color AND foreground_color need to be unique to insert but I don't want that. consider the row exists:
black|blue
and I try to insert:
white|blue
it will insert but if I try to insert another row containing:
black|blue
it will ignore the insert.
Will a primary key of the two cols accomplish this? If so, do I need to also use INSERT OR IGNORE?
First remove the UNIQUE constraint from the definition of the table.
What you can do is create a unique index not on the columns but on the min and max values of the 2 columns:
CREATE UNIQUE INDEX idx_shapes_colors ON shapes(
MIN(background_color, foreground_color),
MAX(background_color, foreground_color)
);
Then, when you try to insert the same combination of colors, like:
INSERT INTO shapes (background_color, foreground_color) VALUES ('black', 'blue');
INSERT INTO shapes (background_color, foreground_color) VALUES ('blue', 'black');
the 2nd statement will fail with an error message:
UNIQUE constraint failed: index 'idx_shapes_colors'
or, if you use INSERT OR IGNORE:
INSERT OR IGNORE INTO shapes (background_color, foreground_color) VALUES ('blue', 'black');
there will be no error but the statement will not insert the row.
See the demo.

OpenEdge BREAK-BY QTY and Sum of rows

I have an orderline table which has QTY field and I would like to group items the way it is shown in image.
I tried using this:
FOR EACH RobotOrderline NO-LOCK
BREAK BY RobotOrderline.OrderedQty.
DISPLAY RobotOrderline.OrderedQty.
END.
But even the grouping seems wrong.
You need to actually sum the quantities. Also the for each still runs for each row in the table, it only orders them and sets flag for different locations in the order (first, last, first-of, last-of).
DEFINE VARIABLE iQty AS INTEGER NO-UNDO.
FOR EACH RobotOrderline NO-LOCK
BREAK BY RobotOrderline.OrderedQty.
iQty = iQty + RobotOrderline.OrderedQty.
IF LAST-OF(RobotOrderline.OrderedQty) THEN DO:
DISPLAY RobotOrderline.OrderedQty iQty.
iQty = 0.
END.
END.

How to Update Value at Column A from Value at Column B in JavaFX TableView?

I have two columns:
TableColumn<class, DatePicker> colCurrentDate;
TableColumn<class, String> colDateAfter3Days;
I want to update value shown in colDateAfter3Days as soon as I change the date in colCurrentDate.
I tried to use setOnCommit() on the colCurrentDate column but it is never called.

How to order table view with numbers 1-2-3

I have a table view , and I want to order my rows
for example first row take 1 , the second take 2
I have tried to use
protected static ObservableList<Employee> data = FXCollections.<Employee>observableArrayList();
int i = data.size() + 1;
in my column
But when I delete row ,
and add new row I got bug in order
for example : I have 2 rows , I have delete the first row,
and add new row it should take different order
but I got same number.
I hope you understand my language .
You can call myTableView.sort(); after you added or removed rows. Of course you have to define the sort order first, with a statement like this: myTableView.getSortOrder().add(myColumn);

How do add column with value derived from other column?

There are three fields in the table quote with columns code, name, close.
I want to create a 4th field type:
if close>10 , type=m else close<=10 , type=n
What SQL statement would I have to use in SQLite?
Update that column with a CASE expression:
ALTER TABLE quote ADD COLUMN type TEXT;
UPDATE quote SET type = CASE WHEN close > 10 THEN 'm' ELSE 'n' END;

Resources