Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-25-2020 11:00 AM
Hey folks, having trouble importing some Excel files - I would like to rename some of the fields on import using the mapping property, but having troubles with field names that have a space in it...
for example, the following works:
CALL apoc.load.xls('/LiveOptics_1101503_VMware_07_23_2020.xlsx', 'ESX-Hosts', {ignore: ['Datacenter','vCenter','Cluster','OS','Local Capacity (GB)','Free Capacity (GB)','Used Capacity (GB)','Guest VM Count', 'ConfigStatus','Boot Time'], mapping: {Model: {name:'wahoo'}}})
But the following yields an error:
CALL apoc.load.xls('/LiveOptics_1101503_VMware_07_23_2020.xlsx', 'ESX-Hosts', {ignore: ['Datacenter','vCenter','Cluster','OS','Local Capacity (GB)','Free Capacity (GB)','Used Capacity (GB)','Guest VM Count', 'ConfigStatus','Boot Time'], mapping: {'Serial No': {name:'wahoo'}}})
The error is below:
Neo.ClientError.Statement.SyntaxError
Invalid input ''': expected whitespace, an identifier, UnsignedDecimalInteger, a property key name or '}' (line 1, column 248 (offset: 247))
"CALL apoc.load.xls('/LiveOptics_1101503_VMware_07_23_2020.xlsx', 'ESX-Hosts', {ignore: ['Datacenter','vCenter','Cluster','OS','Local Capacity (GB)','Free Capacity (GB)','Used Capacity (GB)','Guest VM Count', 'ConfigStatus','Boot Time'], mapping: {'Serial No': {name:'wahoo'}}})"
^
Solved! Go to Solution.
10-25-2020 02:36 PM
Success! I managed to figure out the correct combination of backticks, single and double quotes...
Solution as follows:
CALL apoc.load.xls('/LiveOptics_1101503_VMware_07_23_2020.xlsx', 'ESX-Hosts',{ignore:['Datacenter','vCenter','Cluster','OS','Local Capacity (GB)','Free Capacity (GB)','Used Capacity (GB)','Guest VM Count','Config Status','Boot Time'],
mapping:{
`Serial No`: {name:'serial'},
`Host-Name`: { name:'name'},
Manufacturer: {name:'mftr'},
Model: {name:'model'},
`CPU Sockets`: {type:'int',name:'cpu-sockets'},
`CPU Cores`: {type:'int', name:'cpu-cores'},
`CPU Description`: {name:'cpu-type'},
`Memory (KB)`: {type:'int', name:'memory'}
}
})
10-25-2020 12:42 PM
Note that the only real difference between the two commands is that in the second command there is a space in the name of the imported field ("Serial No").
10-25-2020 02:36 PM
Success! I managed to figure out the correct combination of backticks, single and double quotes...
Solution as follows:
CALL apoc.load.xls('/LiveOptics_1101503_VMware_07_23_2020.xlsx', 'ESX-Hosts',{ignore:['Datacenter','vCenter','Cluster','OS','Local Capacity (GB)','Free Capacity (GB)','Used Capacity (GB)','Guest VM Count','Config Status','Boot Time'],
mapping:{
`Serial No`: {name:'serial'},
`Host-Name`: { name:'name'},
Manufacturer: {name:'mftr'},
Model: {name:'model'},
`CPU Sockets`: {type:'int',name:'cpu-sockets'},
`CPU Cores`: {type:'int', name:'cpu-cores'},
`CPU Description`: {name:'cpu-type'},
`Memory (KB)`: {type:'int', name:'memory'}
}
})
All the sessions of the conference are now available online