I am very new to CYPHER QUERY LANGUAGE AND i am working on relationships between nodes.
I have a CSV file of table containing multiple columns and 1000 rows.
Template of my table is :
cdrType ANUMBER BNUMBER DUARTION
2 123 456 10
2 890 456 5
2 123 666 2
2 123 709 7
2 345 789 20
I have used these commands to create nodes and property keys.
LOAD CSV WITH HEADERS FROM "file:///2.csv" AS ROW
CREATE (:ANUMBER {aNumber:ROW.aNumber} ),
CREATE (:BNUMBER {bNumber:ROW.bNumber} )
Now I need to create relation between all rows in the table and I think FOREACH loop is best in my case. I created this query but it gives me an error. Query is :
MATCH (a:ANUMBER),(b:BNUMBER)
FOREACH(i in RANGE(0, length(ANUMBER)) |
CREATE UNIQUE (ANUMBER[i])-[s:CALLED]->(BNUMBER[i]))
and the error is :
Invalid input '[': expected an identifier character, whitespace,
NodeLabel, a property map, ')' or a relationship pattern (line 3,
column 29 (offset: 100)) " CREATE UNIQUE
(a:ANUMBER[i])-[s:CALLED]->(b:BNUMBER[i]))"
I need relation for every row. like in my case. 123 - called -> 456 , 890 - called -> 456. So I need visual representation of this calling data that which number called which one. For this I need to create relation between all rows.
any one have idea how to solve this ?
What about :
LOAD CSV WITH HEADERS FROM "file:///2.csv" AS ROW
CREATE (a:ANUMBER {aNumber:ROW.aNumber} )
CREATE (b:BNUMBER {bNumber:ROW.bNumber} )
MERGE (a)-[:CALLED]->(b);
It's not more complex than that i.m.o.
Hope this helps !
Regards,
Tom
Related
Is there any way to match the query, for example, I want to search my number against the rules (table name) through query.
I want to match the number which starts with "333" rules .........
1)3322323
Here is my query
SELECT * FROM demo where rules like '33322323';
I want above query return true. because it matches with my rule.
Below is my table.
id | rules
...............
1 | 333
2 | 22
3 | 442
I have sample data 1) 33331235, 2) 2354545 3) 4424545454 4) 22343434
Case 1 (matching data 1) 33331235)
Suppose I want to check my 33331235 with my rules table so my sample data match with my
row 1 which is 333, because of my data start with 333..... it should return true because of it matched.
Case 2 (matching data 2) 2354545)
Suppose I want to check my 2354545 with my rules table so my sample data does not match with my
Any row because my no rule applies on it..... it should return true because of it matched.
Case 3 (matching data 1) 4424545454)
Suppose I want to check my 4424545454 with my rules table so my sample data match with my
row 1 which is 442, because of my data start with 442..... it should return true because of it matched.
Solved.
I solved this with the help of Forpas I used this query to match number start with
SELECT * FROM demo where '333434334 like rules ||'%';
The number at the end of the string when I use this query.
SELECT * FROM demo where '333434334' like '%' || rules;
The number anywhere in the string then I use this query.
SELECT * FROM demo where '333434334' like '%' || rules ||'%';
You need to use the operator LIKE.
You have tagged your question with both MySQL and SQLite.
For MySQL:
SELECT * FROM demo where '33322323' like concat(rules, '%');
For SQLite:
SELECT * FROM demo where '33322323' like rules || '%';
The above code will return all rows where the rules column value is the starting chars of 33322323.
I have a csv file with the following format:
columnA ColumnB ColumnC ColumnD ColumnE ColumnF
1) ABCXYZ 1 123.5 LMN R
2) 08/10/2017 09:07 2 218.81 K
3) 08/10/2017 09:07 YWYI 2 218.81 PQR K
I want to use Java 8 filters/lambda expressions to read this file and to accept rows which have values in COlumnB through ColumnF.
The filter should return two rows (1st and 3rd) for above file. (It does not matter if ColumnA is empty or not).
I am very new to spark.The below is the requirement am getting to
1st RDD
empno first-name last-name
0 fname lname
1 fname1 lname1
2nd rdd
empno dept-no dept-code
0 1 a
0 1 b
1 1 a
1 2 a
3rd rdd
empno history-no address
0 1 xyz
0 2 abc
1 1 123
1 2 456
1 3 a12
I have to generate a file combining all the RDDs for each employee, and the average emp-count is 200k
Desired output:
seg-start emp-0
seg-emp 0-fname-lname
seg-dept 0-1-a
seg-dept 0-1-b
seg-his 0-1-xyz
seg-his 0-2-abc
seg-end emp-0
seg-start emp-1
......
seg-end emp-1
How can I achieve this by combining RDDs? Please note that the data is not written straight forward as it was shown here, we are converting data to business valid format(ex:- e0xx5fname5lname is 0-fname-lname), so need help from the experts here, as the current batch program runs for hours to write data, thinking of using spark to process this efficiently.
I have below records in table.
col1 col2 col3
------------------------
1 Abc IN
2 DEF CA
3 Xyz IN
4 Cae CA
5 Pty IN
6 Zwe DE
7 Zwf US
Here User sends an Input like IN or CA or DE etc. User input has to be mapped against col3. Now I need to query all the records from the table but the records matching the user input (IN or CA or DE) should appear first in the list then all other records should appear. How can I do it using hibernate criteria?
I need the results in below the order if user sends IN as an input.
1 Abc IN
5 Pty IN
3 Xyz IN
2 DEF CA
4 Cae CA
6 Zwe DE
7 Zwf US
You could try to use ORDER BY CASE construct:
order by case when <your entity>.col3 = :parameter then '0' else '1' end asc
There are two ways to solve this problem:
1. Create two queries one with equal to another with not equal to and all results for both in single list.
2. If you don't want to query database twice then you have to write algo in java that will remove elements for your input from list and add it another list and after iteration add remaining list at the end.
try the case ... when statements:
select *, ( case when col3=:input then '0' | col3 else col3 end) as sorter from table order by sorter asc
not sure, if it works, but if it does it would be exactly what you want
I get two cached row sets of data from two tables; table1 and table2.
table1
OrgCode Name Amt FeeCode
1 John 100 R
1 Micheal 200 L
table2
OrgCode AgreementNo AddressNo CustomerNo FeeCode
1 111 211 555 R
1 222 212 666 L
1 333 213 777 P
I need to compare two cachedrow sets, and send the data (cached row set) table to JSP depending on the matching feecode in tables2.
The Sql formed for Cached row set for table-1 is dynamically formed,the same method is used by different classes,with return type cached row set
How might I do this?