I have a list of data in text format that looks as follows
Name1 Name2
location job date amount
Name1 Name2
location job date amount
Name1 Name2
location job date amount
I need to somehow make this into
Name1 Name2 location job date amount
...
I figure there has got to be a way to grab every other newline with either regex or excel. I could write a python script but this file has been a pain and was hoping there would be an easier way to do it.
EDIT: adding what I've tried below:
Sorry, I should have included some code... I tried
([^\n]*\n)[^\n]*\n
in regex, but that groups the two lines together, I basically would like to grab only the newline between the groups. I have also tried doing this in excel systematically but it doesn't continue to grab every other cell when I drag the box down. It changes from every other cell in the column to every cell once I try to extrude it.
The -c 1 flag gets the last character of the file. We pipe this character into wc to check whether it's a newline. If it is, we use head -c -1 to print the whole file except the last character, thus removing the newline. This method uses a temporary file and overwrites the original file with it.
Use printf() when you want awk without printing newline.
Using .Net regex flavoring (should be the same for VBA, but I didn't check), I came up with the following:
Pattern = "([^\n]*)(\n)([^\n]*(\n|\z))"
Replacement = "$1$3"
Basically, catching the first NewLine character in the second capture group and then not returning it in our replacement.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With