How to put one big line of data (it has separators) into a pandas dataframe

I am struggling to get some data into a pandas dataframe (newbie). The data (actually from an URL) is one big line with a comma as columndelimiter and a semicolon as rowdelimiter. Can someone help me with the code? This is what I see in the browser:

20210301,12:25,987,0.359,NaN,408,0.148,NaN,NaN,NaN,NaN;20210301,12:30,1022,0.372,NaN,420,0.153,NaN,NaN,NaN,NaN;20210301,12:35,1057,0.384,NaN,420,0.153,NaN,NaN,NaN,NaN;20210301,12:40,1089,0.396,NaN,384,0.140,NaN,NaN,NaN,NaN;20210301,12:45,1147,0.417,NaN,696,0.253,NaN,NaN,NaN,NaN;20210301,12:50,1200,0.436,NaN,636,0.231,NaN,NaN,NaN,NaN;20210301,12:55,1259,0.458,NaN,708,0.257,NaN,NaN,NaN,NaN;20210301,13:00,1332,0.484,NaN,876,0.319,NaN,NaN,NaN,NaN;20210301,13:05,1401,0.509,NaN,828,0.301,NaN,NaN,NaN,NaN;20210301,13:10,1449,0.527,NaN,576,0.209,NaN,NaN,NaN,NaN;20210301,13:15,1487,0.541,NaN,456,0.166,NaN,NaN,NaN,NaN;20210301,13:20,1534,0.558,NaN,564,0.205,NaN,NaN,NaN,NaN;20210301,13:25,1583,0.576,NaN,588,0.214,NaN,NaN,NaN,NaN;20210301,13:30,1643,0.597,NaN,720,0.262,NaN,NaN,NaN,NaN;20210301,13:35,1701,0.619,NaN,696,0.253,NaN,NaN,NaN,NaN;20210301,13:40,1756,0.639,NaN,660,0.240,NaN,NaN,NaN,NaN;20210301,13:45,1827,0.664,NaN,852,0.310,NaN,NaN,NaN,NaN;20210301,13:50,1967,0.715,NaN,1680,0.611,NaN,NaN,NaN,NaN;20210301,13:55,2099,0.763,NaN,1584,0.576,NaN,NaN,NaN,NaN;20210301,14:00,2248,0.817,NaN,1788,0.650,NaN,NaN,NaN,NaN;20210301,14:05,2388,0.868,NaN,1680,0.611,NaN,NaN,NaN,NaN

This is what I have so far:

import pandas as pd
import urllib as ul

link = "https://xxxxxxxxx"
f = ul.request.urlopen(link)
mydata = f.read()
print(mydata)

Output:

b'20210301,12:25,987,0.359,NaN,408,0.148,NaN,NaN,NaN,NaN;20210301,12:30,1022,0.372,NaN,420,0.153,NaN,NaN,NaN,NaN;20210301,12:35,1057,0.384,NaN,420,0.153,NaN,NaN,NaN,NaN;20210301,12:40,1089,0.396,NaN,384,0.140,NaN,NaN,NaN,NaN;20210301'

I have to add the headers myself also. I don’t know how to get pandas to take it in like this:

| Date     | Time  | Value1 | Value2 | Value3 | Value4
| -------- | ----- | ------ | ------ | ------ | ------
| 20210301 | 12:25 | 987    | 0.359  | NaN    | ...
| 20210301 | 12:30 | 1022   | 0.372  | NaN    | ...
| ...      | ...   | ...    | ...    | ...    | ...

I don’t know which pandas method to use and how. Any help is very appreciated!

Answer

The magic word your are after is read_csv (just follow the link for the doc).

The options for your use case are not trivial and the only foolproof way is to check the doc page, but this is what you want:

df = pd.read_csv(io.BytesIO(mydata), lineterminator=';', sep=',',
                 header=None, names=['Date', 'Time', 'Value1', 'Value2',
                                     'Value3', 'Value4'],
                 usecols=range(6))