I have a string like this and the delimiter is | char,
string = "1234|Google | Alphabet|pest||pp| |||r"
the output I am looking for is,
[1234, Google | Alphabet, pest, "", pp, " ", "", "", r]
I used this,
output = re.split("(?<=\w)\|(?=\w)", string) # but this is giving me wrong output
The issue here is Google | Alphabet is a single word since | is separated by space on both ends. Basically if a | is present with space on both sides its part of that word itself else split it. Can someone tell me a good regex to split it properly. I want to use this regex in pandas.read_csv.
I can write a code to handle this manually but I am looking for a better approach to use as a sep (i.e., since it support regex) in pd.read_csv
Thank you.