Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Split one field into multiple based on a delimiter

$
0
0
I am looking to split one field (BASE) into four based on a delimiter of ^ such as the following:

"PT COM 790 W INTER W LINE^B&S RR & S LINES SW LESS ^E200 ^WEST"

I want

"PT COM 790 W INTER W LINE" to go to field "Line1"

"B&S RR & S LINES SW LESS" to go to field "Line2"

"E200 " to go to field "Line3"

"WEST" to go to field "Line4"

I have searched online and have only seen splits based on X amount of space or only split once, not four times etc. Ex.
Line1 = !BASE!.split(" ", 1)[0]

Any help would be great, thanks.

Viewing all articles
Browse latest Browse all 2485

Trending Articles