I am using google spreadsheet API v4 for java.
My Spreadsheet looks something like this -
User Message Time
--------------------------------
User1 My Message 10:30
User2 User2 msg 3:40
User3 User3 msg 1:30
User2 User2 msg
User4 User4 msg 4:00
I want to find row index with User 'User2' and Time bank (empty value).
After that, I would like to use this row index to add time value in that row.
Is it possible to search row by cell values without knowing range or index?
In above example, it should return me only second last row index as it matches to the criteria (User='User2' and Time='').
or even better, is there any find and replace API, which will find row criteria (User='User2' and Time='') and replace Time value from '' to '3:30'?
I went through google docs, but could not find one according to my need.
Thanks.
Edit:
I found a formula to find cell address which needs to be updated.
=ADDRESS(MATCH("User2",A1:A4000),3)
For example used in this question, this formula will return '$C$4' address, which is expected. I tested this by evaluating this formula in spreadsheet manually. Is there any way using Google spreadsheet API V4 to evaluate this formula using Java code?
I think you'd want to use a combination of lookup functions:
https://support.google.com/docs/topic/3105472?hl=en&ref_topic=3046366
In particular, MATCH lets you get a position offset of the value you want in a range, so you could get the offset of the cells in column1 containing values 'User2', and OFFSET could let you check the value in the cell 2 columns to the right of the found cell, which would give you the value in the Time column to compare with. Since then you'd also have the cell coordiates of the thing checked, you could then assign a new value. These lookup functions allow you to find the range or index that you need for the rest.
This just gives you a handy way to have certain values precomputed for your other functions so that your script can get direct access to values output by the sheets builtin functions. It saves having to have your sheets script sort through a range for a value, but the logic is the same.
1) Get range for Column1
2) Search range of Column1 for value 'User2'
3) If matched, check offset(0,2) to get the cell reference 2 spaces to the right and ask for its cell reference.
4) If that reference is empty, assign it a timestamp.
If you want the code for this, it'll take me a bit longer to put together.
Related
I have a table with a list of items that I need to be able to configure so that when I get a call from a web service I can compare the Long provided against the operator the user entered to pick the correct one.
Sample Data:
ID PropertyID (INT) Compare (varchar)
1 55 >9
2 55 <=9
In this example I'm getting the ID 55 from the web service and an integer/long (e.x. 4). And I want to pick the correct row from my table. In the website the "PropertyID" and "Compare" columns of the table are user configurable.
How would I pick the correct row? Ideally I would have MySQL do the comparison. But if that's not possible I could pull all rows with "55" as the property Id and then have Java do some magic to do the comparison.
With my example I would get row ID 2 since "4<=9".
You can use Spring Expression Language (SpEL) to evaluate the expression at runtime. For reference, please check
https://docs.spring.io/spring/docs/4.3.10.RELEASE/spring-framework-reference/html/expressions.html
Or you can also check at project Evalx
I am giving an object as an input in a Drools decision table.
This object has an "Amount" parameter.
What I would like to do is to compare this received value against a value present in a column in each row. How can I do that?
Basically, I want to compare the input.amount to the value on the same row in the right column.
How can I do that ?
You cannot refer to a value that's given in a column to the right, but it's possible the other way round. Therefore, the columns should be written along these lines (assuming Input is the class name of the object containing the amount):
CONDITION ACTION
Input
$amt:amount insertLogical(new RoutingResult("$param"));
Avail.bal.
100 $amt
200 $amt
300 $amt
If you join the cells, you don't have to repeat $amt in each row.
i'm creating a Itemcode for my inventory system i want the number system of integer values like this using java
for example this
for group 1 the code would be 001 -
0010001,
0010002
for group 2 the code would be 002-
0020003,
0020004
for group 3 the code would be 003-
0030005,
0030006
the items are encoded individually so when i add a new entry it will detect which group it belongs to and generate it desired item code the first 3 digits will be the corresponding Value identification in which group it belongs to the the next 4 digit code will just be the increment value..and would be stored as one integer using MySQL database
You need to decide:
Are the item codes to be represented as: one integer, a pair of integers (group & item), a string ... or something else.
Is the numbering scheme per the first example or the second one. (You seem to have chosen one scheme now ...)
How you are going to populate the items and codes. Do you read the codes? Do you generate them all in one go while loading items from a file. Do you create items and item ids one at a time (e.g. interactively).
How is this information going to be "stored"? In memory only? In a flat file? In a database? (MySQL ... ?)
These decisions will largely dictate how you implement the item id "generation".
Basically, your problem here is that >>you<< need to figure out what the requirements are. Once you have done that, the set of possible solutions will reduce to a manageable size, and you can then either work it out for yourself or ask a sensible question.
I created one birt report.It contains one report parameter with name "FromDate".User will insert it in a fromat like "dd/MM/yyyy". I want to get year(if date is 11/01/2013.i want to extract 2013 from this varaible) from this input parameter and want to pass this value to one stored procedure(ie data set).How can i do that.Can anyone pls share sample code
You could define a variable 'selectedYear' like this:
var selectedValue = params["FromDate"].value;
var selectedValueArray = selectedValue.split("/");
selectedValueArray[2]
This code creates an array by "cutting up" the parameter value on the /'s, and then selecting the year (the second value in the array, which is the third block since we count from zero).
You can then use vars["selectedYear"] on your data set.
Alternatively, if your data set contains a list of years, you can create a data set
select distinct YEAR
from [dataSource]
and have your parameter select from that list instead. This will also guarantee that the selected year is in range.
You can map dataset parameters to report parameter-derived values in the Parameters section of the Edit Dataset dialog:
Select the stored procedure year input parameter from the list of dataset parameters and click Edit... .
Click on the fx button next to the Default Value and select Javascript Syntax .
Enter the formula BirtDateTime.year(params["FromDate"].value) .
Click on OK to confirm these changes in each dialog. (The Linked To Report Parameter option needs to be left as None for that dataset parameter, since you don't want to set the procedure input parameter value to be exactly the same as any of the Report Parameters.)
I had a similar problem in the past, however i looked at from a different angle in driving the date selection from the dates stored in the datasource as a dynamic parameter. Normally then a date from the dataset is in a format which can be formatted/extracted by functions to give the year month day etc.
i tried this one..in corresponding stored procedure i will do a substring on input paramaeter(ie FromDate)..it is working
In sql query(Data Set), Use this
"split_part(?,'/',3)" , We will have date parameter in place of '?' . As, you must be aware of that, Split_part will divide the string using the delimiter '/' .
I am working with a program that i have a record for every user. My users have a property with key, PhoneNumber , and its value is an array of strings, [454457,897356]. For example if i wanted to use cypher query:
Start n=node(1)
Return n
It returns 1 record for my node(one row) that the value of column PhoneNumber is an array.
But i want to have record numbers according to the number of values in my array, means that for my example, the query returns 2 records(2 rows) and all of its attributes be the same but in the PhoneNumber column one of them has the value 454457 and the other has the value 897356. Is any way to do that? do i change my cypher query or make some changes in my java code?
Thanks.
There is no way to do that yet, within Cypher. I've submitted a request for it, though:
https://github.com/neo4j/neo4j/issues/30