cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Missing ID field when importing test file

Hi all,
I have a newbie question. I am trying to import pipe-delimited data using the LOAD CSV function and am having an issue where the first column of my data does not appear to get loaded. The first column is an ID column with numbers and, whether I specify them to be string or int, they get ignored. Here are the commands I used to load the data:

create CONSTRAINT ON (person:PATIENT) ASSERT person.patient_id IS UNIQUE
create CONSTRAINT ON (provider:PROVIDER) ASSERT provider.PROVIDER_KEY IS UNIQUE

LOAD CSV WITH HEADERS FROM "file:///neo4j_patient.txt" as csvLine FIELDTERMINATOR '|' CREATE (Patient:PATIENT {patient_id:csvLine.patient_id, patient_name:csvLine.PATIENT_NAME, DOB:csvLine.DOB, Gender:csvLine.GENDER, Region:csvLine.REGION})

LOAD CSV WITH HEADERS FROM "file:///neo4j_provider.txt" as csvLine FIELDTERMINATOR '|' CREATE (PROVIDER:PROVIDER {provider_id:toInteger(csvLine.provider_key), provider_name:csvLine.PROVIDER_NAME, specialty:csvLine.Specialty, provider_type:csvLine.PROVIDER_TYPE, Region:csvLine.REGION})

There are no errors when I load the data but when I do a MATCH for the patient or provider IDs I get nulls returned. The IDs are not properties of the Patient and Provider nodes.

I am using Neo4j 3.5.14.

Thanks for your help,
Neil

6 REPLIES 6

llpree
Graph Buddy

Few questions -

  1. can you share the first few lines of data in the text files?
  2. make sure you are trimming the number field (id) before you run the toInteger().
  3. Have you run just a "RETURN count(csvLine)" to verify it's the right number?

If #2/3 do the trick, I don't need #1 🙂 Happy to help further.

LP

Hi Llewellyn,
Sorry I can't share the data but I just loaded another file with a similar structure and it looks fine. I will try and delete the patient and provider data and retry.
Thanks for your reply.
Regards,
Neil

intouch_vivek
Graph Steward

@nlennertz,

Apart from suggestion from @nlennertz. Please recheck the Node property you have created while Node Creation and you have used in the Match statement are same.

Hi Vivek,
I did recheck and they were the same. I just loaded another file with a similar structure and it looks fine. I will try and delete the patient and provider data and retry.
Thanks for your reply.
Regards,
Neil

ameyasoft
Graph Maven

The file extension is .txt in. your code. Change the file extension to .csv:

file:///neo4j_patient.csv

Thanks for the suggestion. I found my issue was with my SQL background and not being strict with names. A field called PATIENT_KEY in my data file would not be imported as a property if I called it Patient_Key in my load CSV statement.