I have data (below) with three different delimiters (the first has a space to the number, the second 3 spaces to the number and the final column a space and then a tab to the number) and I want to be able to generate a list containing sequential values from each column.
8000.5 16745 0.1257
8001.0 16745 0.1242
8001.5 16745 0.1565
8002.0 16745 0.1595
8002.5 16745 0.1093
8003.0 16745 0.1644
I tried some stuff with re. after converting to a string to see if I could parse it this way but it seemed a little bit long-winded to convert and I was wondering if anyone knew a quicker way. Ideal output would be
list 1 = [8000.5, 8001.0, 8001.5 ...]
list 2 = [16745, 16745, 16745, ...]
list 3 = [0.1257, 0.1242, 0.1565, ...]
Thanks!
Just use a
.split(); it’ll take any amount of whitespace and split on that (ignoring leading and trailing whitespace altogether):If you need floats instead of strings, simply apply
float()to each value usingmap: