Proper Cypher regular expression examples

So, there is a "display" form of the data and the "float" form if you want to do math (e.g. multiply quantity x price).

Did you try RETURN price[0]?

I think that will return the string.

Here's a fragment to show you what you can do (and I'm still not quite clear what you want...)

WITH [["120,24"]] as price  // Sets the variable price
 RETURN price[0] // Returns the first element in the List of Lists, which is a List

will return a list

["120,24"]
WITH [["120,24"]] as price // Sets the variable price
RETURN price[0][0] // Returns the string

will return "120,24"

Hello Clem,

Yes, I have gotten this far with the input from you and cobra. But when I try to use toFloat(Price[0][0] ).
I get all values back as NULL.

See screen shot.

So I do the following:

with price[0][0] as pr

RETURN toFloat(pr)

Hello Clem,

I missed that you said that I needed to replace the "," before I can apply the float function to the returned values. It really is the little details. I am guessing that is why I was getting "NULL" as return below.

You might experiment with this:

I think it can do what you want.... It doesn't have a lot of examples, plus you have to delve into the Java implementation of how the conversions are done to see if it work the way you want.

In particular:

RETURN apoc.number.parseFloat('12.345,67', '#,##0.00;(#,##0.00)', 'it')

returns 12345.67

Hello Clem,

This is how I solved it

// Apoc JSON ADD STORE & INVENTORY
CALL apoc.load.json("file:///lego3-5.json") YIELD value 
WITH value AS v
WITH apoc.text.regexGroups ( v.Product_Price, '\\d{1,3},\\d{1,2}' ) as price
with price[0][0] as pr
WITH REPLACE(pr,",",".") AS prnew
RETURN toFloat(prnew)

output

I do like the link you sent, really something new to learn. I find APOC to be a bit daunting at times, in that they hardly give any explanation, and being that I am learning CYPHER, I often can't get the context right away.

What is APOC really based on, is it coming from the Java point of view, so is it so that if I knew JAVA, I would quicker get the apoc stuff better/quicker?

You know what I would really like to understand is the following. What doea this mean / comes from?
" :: " the double colon. I see it in explanations in APOC and also XPATH documentation. Where does it come from, and what is it?

Java is the underlying code for Neo4J (including APOC) but that is essentially transparent. For us, Neo4J could have been programmed in anything else and 99% of time, we wouldn't be able to tell the difference. (There are some JVM related configuration parameters.)

The key thing for Neo4J, is APOC allows new functionality to be easily added to Cypher without changing Neo4J itself. That also means the APOC libraries can be updated without having to make a new Neo4J release. In addition, APOC can leverage the existing Java libraries. It's just a simple matter of putting an APOC wrapper around the Java call. That means when somebody says, "I wish Neo4J had a function to do X", it can be easily added if it already exists in the JVM world.

The :: notation is new to me but I can tell that the token after the :: is the type of a Cypher thing expected in the APOC function or procedure call, like a STRING or NODE. My guess is the ? means the argument is optional.

The weird thing is YIELD which I don't quite understand.... but I just follow the documentation.

APOC is nothing to fear: just experiment with data you don't care about, or you can do something like:

WITH '12.345,67' AS cost
RETURN apoc.number.parseFloat(cost, '#,##0.00;(#,##0.00)', 'it')

Hope that helps! (I'm somewhat new to Neo4J, but I have experience with lots of languages and systems and some with SQL, so I can make decent guesses about what's going on!)

Thank you clem,

i am new to Neo4J (2019) , and am learning Python at the same time. Last time I programmed it was with Borland Pascal. I am really liking Python, Just learned Regex last week because I needed it for this situation. Learning xPath now, by Monday I should have it under control, Xpath is a funny thing, it can do some really super complex selects, and at the same time, you can do alot with the simple stuff.

I don't see much about Neo4J and deep learning and machine learning, it's always showcased for fraud detection and network related stuff.

I come from Filemaker Pro, and reached a point where I started to have to make some crazy join tables just to do some simple queries, so I started looking around, and found Neo4J. I started to hate the query builder in Filemaker, it is cumbersome.

Neo4J has this library that might be relevant to you. It imports XML so maybe it would be better to import into Neo4J and do your queries that way.

Since you're interesting in Python, this might be interesting to you too:

https://py2neo.org/

There is some stuff about Neo4J and ML.

My suspicion is (for now) you need to export the data into something a ML algo can ingest (e.g. a table, or .CSV file.). I suspect that most ML people think in terms of tables and not graphs (yet).

I believe if somebody is motivated enough, they would create an APOC to interface with a ML algo to handle specific use cases.

I think for Fraud, Neo4J is more of a browsing and hunting tool.

Just my opinions...

Best wishes in your learning of Neo4J!