Load CSV split

Hi guys,

Id like to split the following csv column into 2. The split being between the first 2 charactors e.g the first one would split into LA and 05

St/Dis (Header)
LA05
NC12
AL04
CA31
GA12
TX32
MI03
NV02
ND00

Kind regards,
Sam

not exactly sure if you are simply wanting to split the data in CSV file itself and rewrite the file or if u want to read the data and then split based upon the 1st 2 characters using a Cypher statement but this should be possible via the SUBTRING() function

If your field is only 4 characters, the easiest way would be to use left() and right() to get the leftmost and rightmost characters:

... //assume row is the variable from LOAD CSV
WITH row, left(row.`St/Dis`, 2) as state, right(row.`St/Dis`, 2) as dis
...

If the Dis part can be more than two characters, then you'll want to use substring() instead like Dana suggested:

substring(row.`St/Dis`, 2) as dis

brillant thanks lads