Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

sorting for multi-character

hello all i’m trying to solve the sorting for multi-character. below is the couple for lines from the data.

data = pandas.read_csv('data.csv')
data

001@|@02@|@ABC@|@IND123
002@|@02@|@ABC@|@IND223
003@|@02@|@ABC@|@IND333
004@|@02@|@ABC@|@IND443

i am trying with the below code:

res = re.split('@|@',data)
print(res)

001@|@02@|@ABC@|@IND123

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

['001', '|', '02', '|', 'ABC', '|', 'IND123']

please suggest, thanks in advance

>Solution :

pd.read_csv('data.csv', header = None, sep='@\\|@', engine = 'python')

    0   1   2   3
0   1   2   ABC IND123
1   2   2   ABC IND223
2   3   2   ABC IND333
3   4   2   ABC IND443
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading