I am trying to split data with multiple delimiters from a txt file. I've tried all sorts but for some reason this will not work
The data looks like this.
MOD001|Zacharias Karstensen|2|MOD002,MOD003,MOD004,MOD005,MOD006,MOD007,MOD008,MOD009,MOD010,MOD013
MOD002|Dominykas Cleary|2|MOD001,MOD003,MOD004,MOD005,MOD006,MOD007,MOD008,MOD009,MOD010,MOD013
MOD003|Zacharias Karstensen|2|MOD001,MOD002,MOD004,MOD005,MOD006,MOD007,MOD008,MOD009,MOD010,MOD011,MOD012,MOD013
I am trying to split by pipe (|) and commas (,), then store the results in a 2d array.
I'm reading the data in the following manner:
with open('Modules.txt', 'r') as fr:
data = fr.read()
data = data.split('\n')
I can get it to work with a pipe delimiter like so:
data = [n.split('|') for n in data]
data = pd.DataFrame(data)
modules = np.array(data)
Your help is greatly appreciated.
Thanks!