Hi @Novice ,
this is my code, please give a try
demo.csv
n
{name:CVE-2014,count:1,asset_id:1111,privilege:0,seq:1}
{name:CVE-2015,count:12,asset_id:2222,privilege:0,seq:2}
{name:CVE-2016,count:31,asset_id:3333,privilege:0,seq:3}
Cypher Query
CALL apoc.load.csv('demo.csv' ,{skip:1,header:FALSE} )
YIELD list
with apoc.convert.toString(list) as base
WITH ['\{', '\}','\[','\]', 'name:','count:','asset_id:','privilege:','seq:', '\"'] as to_remove, base
with base, reduce(vari=base, word in to_remove | apoc.text.replace(vari,word,'')) as filtered
with apoc.convert.toStringList(split(filtered,",")) as tt
create (a:Item) set a.name = trim(tt[0]), a.count=toInteger(trim(tt[1])),a.asset_id=toInteger(trim(tt[2])),a.privilege=trim(tt[3]),a.seq=toInteger(trim(tt[4]))
Result -
match(n) return(n)
╒══════════════════════════════════════════════════════════════════════╕
│"n" │
╞══════════════════════════════════════════════════════════════════════╡
│{"name":"CVE-2014","count":1,"privilege":"0","asset_id":1111,"seq":1} │
├──────────────────────────────────────────────────────────────────────┤
│{"name":"CVE-2015","count":12,"privilege":"0","asset_id":2222,"seq":2}│
├──────────────────────────────────────────────────────────────────────┤
│{"name":"CVE-2016","count":31,"privilege":"0","asset_id":3333,"seq":3}│
└──────────────────────────────────────────────────────────────────────┘
Note -
- above script has CREATE not MERGE. So, be careful with incremental inserts. make sure the csv files doesn't have duplicates. (you can create constraint, but didn't try it).
- I didn't know about the data, so have few data converted to int.
- i doubt your csv file. was it originally a json file and then you removed "," at the end ? I am not sure.
give it a try and let me know how it goes.