Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-27-2020 01:30 PM
Dear Everyone,
I am setting some properties on a few nodes. Here is the query I am attempting to execute.
match (i:Invoice {InvoiceNr:"1456735/2553"})
MERGE (i)-[:SUB_INVOICE]->(si:Invoice{InvoiceNr:"102435433/231",Total:197,30})
RETURN i,si
How do I get the value with the comma to ne escaped. I did a search in the manual for escape characters, but just got stuff on loading CSV data and regular expressions.
Kind regards,
Tideon
02-27-2020 05:11 PM
Would converting it to a string first help? What's the aim of having the comma escaped?
02-27-2020 07:59 PM
Hello,
Becasue I am building the database in europe where we use commas. So 10,20 instead of 10.20
Kind regards,
Tideon
02-27-2020 09:20 PM
I understand that's the currency separator, but I still don't understand why you want it "escaped"?
02-28-2020 12:56 PM
I tried to add it to the property and Cypher thinks that everthing after the comma is a new property. So I get an error saying it is expecting a key value pair in essence. So Total: 197 and then OtherPrice: 30
So that is why I thought maybe escaping it would allow cypher to understand what I am trying to do.
You may have a better solution.
Kind regards,
Tideon
02-28-2020 01:14 PM
Hi - are you expecting this?
match (i:Invoice {InvoiceNr:"1456735/2553"})
MERGE (i)-[:SUB_INVOICE]->(si:Invoice{InvoiceNr:"102435433/231",Total:"197,30"})
RETURN i,si
or
match (i:Invoice {InvoiceNr:"1456735/2553"})
MERGE (i)-[:SUB_INVOICE]->(si:Invoice{InvoiceNr:"102435433/231",Total:'197,30'})
RETURN i,si
02-28-2020 01:17 PM
Hello Kailash,
Does the second one allow the 197,30 to remain a number?
As I believe the first one turns it into a string. An I correct?
I need the numbers to do calculations down the line.
Kind regards,
Tideon
02-28-2020 01:50 PM
No, Sorry . this remains as String
02-28-2020 01:51 PM
For clarity, both queries will turn it into string?
How do I enter it as a number?
02-28-2020 01:58 PM
Hi @tideon - I will let others answer but i dont think we can have comma in Int type.
02-28-2020 02:15 PM
Try this:
return toFloat(replace("197,30", ',', '.'))
result: 197.3
02-28-2020 07:16 PM
I don't believe that Neo4j has a configurable decimal separator, it recognises only .
Storing your values as strings is probably your best bet, and then if you need to perform calculations on them you can convert using toFloat on the fly e.g:
with "6,10" as firstVal, "5,10" as secondVal
return toFloat(replace(firstVal, ",", ".")) - toFloat(replace(secondVal, ",", "."))
02-28-2020 08:13 PM
I think you're getting caught up on the visual display of the data vs. how it needs to be stored in a database. Store it as an int 19730
, and let the website/UI handle the formatting of the data. Computers don't care about local formatting. Another example of this would be a date. Different regions display dates differently but you still store the information as a date data type and handle the display formatting in the UI.
02-29-2020 03:48 PM
You have to manage the same on the fly only.
All the sessions of the conference are now available online