Python open a csv document that have different types of separators

  csv, pandas, python

I have a txt document with the following structure:

1:0.84722,0.52855;0.65268,0.24792;0.66525,0.46562
2:0.84722,0.52855;0.65231,0.24513;0.66482,0.46548
3:0.84722,0.52855;0.65197,0.24387;0.66467,0.46537

The first number with the colon is the index, and I don’t know how to indicate it when I open the file. Indeed I would like to erase it.
Then data is separated with commas and semicolons and I would like to have each number in a different column, regardless of whether the separator is a comma or a semicolon.
How could I do it?

Source: Python Questions

LEAVE A COMMENT