Thank you, Fletcher.
The first few steps worked perfectly. The data now look like this:
ART 200
Alternate
Dove, David 11
Fox, Fred 11
Gill, Gertrude 10
But when I run this step:
\r(.+?)\r\t(.+?)\r\t\t(.+?)\r
it acts on most of the student names, but not all of them. I'm not able to
detect a pattern in the sequence of the skips, or any difference in the
textual structure of the skipped records. The records are now structured
enough that I can drop them into a spreadsheet and do some manual fill
down, but I would like to figure this out, since this is a recurring
project.
dp
On Wednesday, March 22, 2023 at 11:36:27 AM UTC-5 Fletcher Sandbeck wrote:
> I feel like this would be easier with a script of some sort. Nevertheless
> the idea I had was to do the following.
>
> First, use Shift Right to push all the data in two tab stops. And make
> sure there's an empty line at the start and end of the file.
>
> ART 215-2D Art II, Honors
> First Level Requests
> Kite, Kevin 11
> Lizard, Larry 12
> Mongoose, Marvin 11
>
> Then use a couple search/replaces to pull the ART and First/Alternate
> lines forward and fix the data to what you want at the end.
>
> Find: ^\t\t([A-Z]+ [0-9]+).*$
> Replace: \1
>
> Find: \t\tFirst Level Requests
> Replace: \tFirst
>
> Find: \t\tAlternate Request
> Replace: \tAlternate
>
> Now, the data looks like this:
>
> ART 200
> Alternate
> Dove, David 11
> Fox, Fred 11
> Gill, Gertrude 10
>
> Collapse the first three rows in each group with this search replace. Make
> sure you start at the top of the file and only run it once.
>
> Find: \r(.+?)\r\t(.+?)\r\t\t(.+?)\r
> Replace: \r\1\t\2\t\3\r
>
> ART 215 First Kite, Kevin 11
> Lizard, Larry 12
> Mongoose, Marvin 11
>
> And then fill the data down into the remaining rows by running this
> replacement several times.
>
> Find: \r(.+?)\t(.+?)\t(.+?)\t(.+?)\r\t\t(.+?)\t(.+?)\r
> Replace: \r\1\t\2\t\3\t\4\r\1\t\2\t\5\t\6\r
>
> ART 200 First Aardvark, Amy 10
> ART 200 First Badger, Billy 11
> ART 200 First Cat, Carl 12
>
> Remove Blank Lines and the data should be importable.
>
> [fletcher]
>
> On Mar 22, 2023, at 8:40 AM, Doug Pinkerton <[email protected]> wrote:
>
> I need to convert data formatted for humans into data formatted for a
> database. The actual document is subject to privacy regulation. The
> following is a mockup to illustrate the task. I need to convert this:
>
> ART 200-2D Art I
> First Level Requests
> Aardvark, Amy 10
> Badger, Billy 11
> Cat, Carl 12
>
> ART 200-2D Art I
> Alternate Request
> Dove, David 11
> Fox, Fred 11
> Gill, Gertrude 10
>
> ART 215-2D Art II, Honors
> First Level Requests
> Kite, Kevin 11
> Lizard, Larry 12
> Mongoose, Marvin 11
>
> into this:
>
> ART 200 First Aardvark, Amy 10
> ART 200 First Badger, Billy 11
> ART 200 First Cat, Carl 12
> ART 200 Alternate Dove, David 11
> ART 200 Alternate Fox, Fred 11
> ART 200 Alternate Gill, Gertrude 10
> ART 215 First Kite, Kevin 11
> ART 215 First Lizard, Larry 12
> ART 215 First Mongoose, Marvin 11
>
> So, I need to capture the course ID from one line, the request type from
> the next line, and then insert each of those into the beginning of each
> subsequent line, until the occurrence of a new course ID, at which point
> the course ID and request type are updated for insertion into the next
> block of lines...
> ... and so on for about 3,000 lines.
>
> My grep skills are not up to the challenge. Can anyone help?
>
> Thanks,
> dp
>
> --
> This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email "[email protected]"
> rather than posting here. Follow @bbedit on Twitter: <
> https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google Groups
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/446f907e-e61f-45c4-946a-261fafa0fa7an%40googlegroups.com
>
> <https://groups.google.com/d/msgid/bbedit/446f907e-e61f-45c4-946a-261fafa0fa7an%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or need technical support, please email "[email protected]" rather than
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/dfd9be40-15f1-4ad3-98e3-f0cdda2fe5a7n%40googlegroups.com.