Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-18-2020 03:08 AM
this being the content of my "taxonomy.CSV" file:
Level1,Level2,Tree Path,Id,Code,Description,Long Description,Context,Type,Active,Code Valid from,Node Valid from,Node Valid to
1,1,(Root Code),31102727,Zone,Zone,,TEST,Taxonomy,A,31/01/2020,,
2,2,31085110,31085110,CAI,Asia,,TEST,Zone,A,4/8/2017,,
by running
CALL apoc.load.csv('taxonomy.csv') yield map return map,map['Id'],map['Tree Path'],map['Level1'],map['Level2'] limit 5
I cannot access the values on the first column - they are always null.
I've tried renaming the column -> same (=null).
I've duplicated the column, initially called "Level" and new it's Level1 and Level2 and Level2 can be access, but Level1 is always null
Result (removed some content from map to make used fields more visible):
map
{
"Tree Path": "(Root Code)",
"Level2": "1",
"Level1": "1",
"Id": "31102727"
}
map['Id'] map['Tree Path'] map['Level1'] map['Level2']
"31102727" "(Root Code)" null "1"
Is there some parameter i am missing, some little frustration disabler flag i need to use?
09-18-2020 04:14 AM
@gabriel.toma have you tried map.Id, map.Level1, map.Level2
?
LOAD CSV WITH HEADERS
makes the fields accessible in this way. I'm ASSUMING that apoc.load.csv uses the same logic underneath.
09-18-2020 06:06 AM
well, the reason I use the apoc variant is that LOAD CSV only outputs just "line", whereas for apoc.load.csv also outputs the map of the line, which I can use to setup the node immediately, using set p = map (p being the new node).
With LOAD CSV I would need to individually access each and every attribute, which is a no-go for my purpose.
09-18-2020 12:23 PM
If you use WITH HEADERS it gives you a map as well.... or it does for me (v 3.5.17 enterprise)
pretty standard pattern for us is to import a row, parse the fields that need formatting, then load the rest into the Node.
LOAD CSV WITH HEADERS FROM
'https://somewhere.com/sample.csv' AS line
CREATE (n)
SET n += line
09-18-2020 10:05 PM
Thanks, Mike, will try this.
09-19-2020 06:15 AM
Hi Gabriel,
Hi have experienced the same problem accessing the first column when using apoc.load.csv.
Using the classical LOAD CSV including the statemen 'WITH HEADERS' is definitely an option. But not in my case. Apoc.load.csv also return with an index per line, which is crucial in my case. Classicla LOAD CSV does not provide this index per line. So I am still stuck, due this potential buck within apoc.load.csv
My workaround: I am adding an empty column at left of my csv file BEFORE running apoc.load.csv
Best
Markus
09-20-2020 11:47 PM
Thank you, Markus
In the end, I did the same (adding a column before the first column)
Opened https://github.com/neo4j/neo4j/issues/12587
10-01-2020 01:24 AM
Can you folks please check if you have a byte order mark
character at the beginning of your file? That could potentially pollute the header string.
Maybe use hexdump or similar tools to inspect.
To get rid of BOM run
sed '1s/^\xEF\xBB\xBF//' < orig.txt > new.txt
12-18-2020 01:41 PM
All the sessions of the conference are now available online