How to produce a formatted report from LibreOffice Calc spreadsheet? - report

I have a very simple LibreOffice Calc spreadsheet with column headers and columns (cell can be multiline), someting like:
| id | Prio | Domain | Comment | ... |
|----|------|--------|----------------|-----|
| 1 | A | Foo | Something | |
|----|------|--------|----------------|-----|
| 2 | A | Bar | Something else | |
| | | | Possibly on | |
| | | | multiple lines | |
|----|------|--------|----------------|-----|
| 1 | C | Baz | Something else | |
I would like to obtain, in a (semi) automated way a plain text file containing something like:
id: 1
Prio: A
Domain: Foo
Comment: Something
...
id: 2
Prio: A
Domain: Bar
Comment: Something else
Possibly on
multiple lines
...
id: 3
Prio: C
Domain: Baz
Comment: Something else
...
Is this possible somehow?
I am aware of LO macro capabilities (e.g.: this ), so the trivial answer is probably "yes", but I never used them so I would need some guidance (I don't even know how to use such a thing).

There are a lot of different ways this could be done. One idea is to go to File -> Save As and save as type CSV. In the filter settings, check Quote all text cells to make it easier to handle newlines.
Then write a script that uses the python csv module, for example:
import csv
with open('Untitled 1.csv') as csvfile:
spamreader = csv.reader(csvfile, dialect='excel',)
for row in spamreader:
print("row: ", end="")
print(', '.join(row))
To avoid the Save As step, you could write a macro instead. It might be easier to write it in python rather than Basic, because file handling and string manipulation can be difficult in Basic.

Related

parameterize examples in cucumber queries

I am new to Cucumber. I have a requirement to use variables instead of actual values in a feature file example. Actual values are to be populated in a separate property file.
Sample feature file:
#tag
Feature: Add an element to stack
The user pushes an element. It gets added to stack
#tag1
Scenario: Push element to empty stack
Given Stack is empty
When User pushes an element
Then stack should have only one element
#tag2
Scenario Outline: Push element to stack
Given Stack has {initial} elements
When User adds {new} element
Then Length of stack increases to {new_size}
| initial | new | new_size |
| 1 | 2 | 2|
| 5 | 9 | 6|
| 0 | 3 | 1|
The output example should be like:
| initial | new | new_size |
| {val1_1} |{val1_2} | {val1_3}|
| {val2_1} |{val2_2} | {val2_3}|
I have used "{}" instead of "<>" as am not able to print elements inside <> in pre-formatted code
Use scenario outlines with examples. Its will solve you data input based queries. For example,
#tag2
Scenario Outline: Push element to stack
Given Stack has <initial> elements
When User adds <new> element
Then Length of stack increases to <new_size>
Examples:
| initial | new | new_size |
| 1 | 2 | 2 |
| 5 | 9 | 6 |
| 0 | 3 | 1 |
And your step definition would be like this,
Given("^Stack has (.*) elements$", (String initial) -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
Similarly do for the other query parameters like (name, new_size).

Fulltext Search in Neo4j

I have question on full text search using neo4j. Followed the instruction in the webpage, i enabled the full text search.
Full Text Search Guide
CREATE (p:Place {name:"Chicago"})
1) Run the command: START n=node:node_auto_index("name:*C*") RETURN n;
Result:
+------------------------------+
| n |
+------------------------------+
| Node[65263]{name:"Chicago"} |
+------------------------------+
1 rows
2) Run the command: START n=node:node_auto_index("name:Chicago") RETURN n;
Result:
+---+
| n |
+---+
+---+
0 row
3) START n=node:node_auto_index("name=Chicago") RETURN n;
Result:
null
My question is: How can modify the search (2) START n=node:node_auto_index("name:Chicago") RETURN n; to give the result Chicago ?
Also, would we not specify the field name in the command, (i.e. search all fields which contains "Chicago" keyword in all nodes) ?
Thanks.
You can use schema indexes for exact matches.
CREATE INDEX ON :Place(name)
For more info see
http://neo4j.com/docs/developer-manual/current/cypher/schema/index/
If you, for some reason, still need to do an exact match try this syntax:
START n=node:node_auto_index(name="Chicago") RETURN n;
Can you try like this ?
Exact match Chicago -
START n=node:node_auto_index('(name:(Chicago))') RETURN n;
Match all nodes with name property containing Chicago -
START n=node:node_auto_index('(name:(Chicago)') RETURN n;

TypeScript signature for a recursive Flatten Function

I'm working on building a Typescript .ds file for reactive-coffee (http://yang.github.io/reactive-coffee/api.html), and I'm running into trouble trying to figure out the type signature for the flatten function. An example:
flatten(rx.array([1, [2, 3], rx.cell(4), rx.array([rx.cell([5, rx.cell(6)])])]))
// -> [1,2,3,4,5,6]
flatten([1, [2, 3], rx.cell(4), rx.array([rx.cell([5, rx.cell(6)])])])
// -> [1,2,3,4,5,6]
The question I'm running into trouble with is: what is the correct Typescript type signature for xs? So far I've come up with something like this:
interface NestableCell<T> extends ObsCellInterface<T | NestableCell<T>> {}
type Flattenable<T> = (
Array<T| NestableCell<T | Flattenable<T>> | Flattenable<T>> |
ObsArrayInterface<T | NestableCell<T | Flattenable<T>> | Flattenable<T>>
)
function flatten<T>(xs:Flattenable<T>) => ObsArrayInterface<T>
ObsCellInterface and ObsArrayInterface are typed versions of RC's ObsCell and ObsArray objects, respectively.
Unfortunately, Typescript does not allow recursive types, only recursive interfaces. And at this point I'm really not sure how to convert that type to an interface.
The following seems to work, though I haven't yet had time to prove that it satisfies all possible cases:
interface NestableCell<T> extends ObsCell<T | NestableCell<T>> {}
interface FlattenableRX<T> extends ObsArray<
T |
NestableCell<T | FlattenableJS<T> | FlattenableRX<T>> |
FlattenableJS<T> |
FlattenableRX<T>
> {}
interface FlattenableJS<T> extends Array<
T |
NestableCell<T | FlattenableJS<T> | FlattenableRX<T>> |
FlattenableJS<T> |
FlattenableRX<T>
> {}
export type Flattenable<T> = FlattenableRX<T> | FlattenableJS<T>
Using two mutually recursive interfaces appears to avoid the worst complications from having to support both primitive and reactive arrays.
As I said, I cannot yet prove that this works, but it at least seems plausible.

Robot framework call soap method with Array parameter

I have a Java Soap service with method
public void helloStudentsName(String[] names)
And user robot framework (SudsLibrary) to call this, because i didn't fine Array in Robot so i use List in code
${names} Create List name1 name2 name3
Call Soap Method helloStudentsName ${names}
I got error
TypeNotFound: Type not found: 'arg0'
And replace $ by # in list declare
#{names} Create List name1 name2 name3
Call Soap Method helloStudentsName #{names}
No error but in Java method receive an empty array.
Can you show me how to call this method?
I think you need to create a special WSDL array object, rather than using a plain robot list. SudsLibrary has a keyword for this, and uses it in an example.
Assuming your WSDL defines a type of ArrayOfString, you might do something like this:
| | ${string array}= | Create Wsdl Object | ArrayOfString
| | Append To List | ${string array} | name1
| | Append To List | ${string array} | name2
| | Append To List | ${string array} | name3
| | ${result}= | Call Soap Method | helloStudentsName | ${string array}
This will only work if your WSDL defines a type of ArrayOfString. Your actual WSDL might call it by some other name.

String pointers

Consider the following program (http://play.golang.org/p/IbAstvudtE):
package main
import (
"fmt"
)
func changeStringValueNotOK(dest *string, src string) {
dest = &src
}
func changeStringValueOK(dest *string, src string) {
*dest = src
}
func main() {
a := "Hello"
b := "World"
changeStringValueNotOK(&a, b)
fmt.Println(a) // still "Hello"
changeStringValueOK(&a, b)
fmt.Println(a) // now "World"
}
My goal is to call a function and change the value of string. Works fine with the second function, but not with the first.
Question: what is the meaning of *dest = src compared to dest = &src? I guess the former is "the contents of dest is now src" and the latter is "change the dest variable so that it now points to the address of src" which discards the previous value, but not the contents of a. But even if I am right, I don't understand how the *dest = src works.
I hope my question isn't too fuzzy.
*dest = src
is: Set the value pointed at by dest to the value in src. So it's effective.
dest = &src
is: Set the value of dest to the address of src. As dest is a formal parameter of changeStringValueNotOK the change (to the pointer only, not to the pointee) is visible only locally. As the changed value is not really used, it's total effect is a no operation.
Just to help visualize it graphically, in your main function you have this:
Data Variables
| ... |
-------
| Hello |<----- <a string>
-------
| World |<----- <b string>
-------
| ... |
When you provide the parameters to either of these functions, it becomes:
Data Parameters
| ... |
-------
| Hello |<----- <a string> <----- <dest *string>
-------
| World |<----------------------- <src string>
-------
| ... |
With that scenario, when you do *dest = src, you get:
Data Parameters
| ... |
-------
| Hello | ,- <a string> <---- <dest *string>
------- |
| World |<--/
| |<---------------------- <src string>
-------
| ... |
Note that this effectively changes a itself, so when you return to the prior scope, you'll observe the change.
On the other hand, if you do dest = &src, you'd instead get:
Data Parameters
| ... |
-------
| Hello | <dest *string> ----,
------- |
| World |<---------------------- <src string> <---/
-------
| ... |
Which doesn't solve your problem, because both dest and src are local to the functions they're in.
As a side note, this kind of parameter passing is a common C idiom, but in Go you'd generally change such a string by returning the new value instead.

Resources