Every week at work I get a .txt file which is basically survey results. Format is something like this:
1/02/25
893747 (always six digits)
Jeff
Completely Agree
Disagree (this line is optional, not always present)
Neither Agree Nor Disagree (optional)
Random Comments (optional)
1/07/25
I have to take dozens of entries like that and I manually turn them into this:
893747
Jeff
Completely Agree
1/07/25
I bet there's a way to automate this. Anyone have any suggestions?
Maybe an awk script; if each entry has the same number of lines in the same position, you could use the NR builtin variable to reorder the output; but I bet some sick twisted individual would want to do it in perl. Though I'd probably use Python
@botvolution see, that's the complication - because there are three optional questions, some entries have three extra lines, otherwise I could just use regex to select and delete eveything I don't need. That might still be possible, but I'm not great with regex so the best I've managed so far is running half a dozen search-and-replaces for every permutation of 2 or 3 answers, using a regex to delete every odd occurence of a date and then manually removing the comments if they're present.
@prokyonid
Yeah as I was typing I thought, I bet the input is inconsistent, these kind of problems are sometimes not worth the effort of automating tho