I have a text file with data like these:
ISP-123456 2 2 2 2
ASI-123213 2 3 1 5
PSI-123233 3 2 3 7
SRI-213232 1 4 9
SIR-122323 1 2 24 0
Suppose I want the last two values from each row (2 2, 1 5, 3 7, and 4 9), how can I achieve this? Note that these rows do not have the same number of column, but the values are always in the correct position. I'm thinking about a regular expression that will trim data starting with the second whitespace counting from the end of each row.
Update:
Thank you for the responses! But they remind me that I should be more clear with my question. Sorry for the incomplete example. I have added row five. As can be seen, the values can have more than one digit (24 0). In this case I still want the last two values of each row.
Solved! Go to Solution.
Hi @45179902
I was able to increase it to 4 digits above that position will anyways break. If provided there is a space in between n-digits of numbers this code will work.
Hope this helps : )
Hey @45179902 I had another go at this, and I think this works:
Taking @atcodedog05's testing values, I think if you replace up to 5 spaces with a pipe (|) and then split to rows on that it should work, at least with the sample data you've given us. You might need to test on the full data to see if that max value of 5 is correct...
Ollie
User | Count |
---|---|
56 | |
27 | |
25 | |
23 | |
21 |