Re: Capturing multiple variables in regular expression

2023-03-23 Thread Doug Pinkerton
On second thought, since that went better than I imagined possible, it 
makes me bold to think that perhaps the entire mess can be cleaned up 
without any manual work. The attached file is a sample of the real thing, 
except that I’ve replaced all of the students’ names with “Lastname, 
Firstname”. This is copied from a screen print, which is the only way to 
get these particular records out of the SIS. I can grep the removal of sex, 
grade, campus, and totals, which are irrelevant for this project. And with 
Chris’s script, I can now make the stacked data tabular.

What remains is the column wrapping issue. Some courses consist of the 
header information followed by a short student roster. These present no 
problem. But if the roster is too long to fit on a page, the report creates 
a second column next to the first, without regard for alignment. So, the 
first record in the second column often ends up next to the course name. In 
each case where such wrapping occurs, I need to move the second column to 
the bottom of the first column, but can’t think of any way to do it other 
than manually. And that’s even more tedious than it seems. The sample is 
artificially clean. In the real document, the variation in the lengths of 
the student names creates a ragged edge to the first column, such that the 
second column weaves in and out. It’s not possible to do a rectangular text 
selection. 

Can anyone help with this?

On Thursday, March 23, 2023 at 8:21:25 AM UTC-5 Doug Pinkerton wrote:

> Wow. Problem resolved. The script is bulletproof.
> Thanks very much to both of you. Your gracious expertise has saved me a 
> lot of time.
>
> dp
>
> On Wednesday, March 22, 2023 at 4:58:07 PM UTC-5 Christopher Stone wrote:
>
>> On Mar 22, 2023, at 10:40, Doug Pinkerton  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:
>>
>> --
>>
>> Hey Doug,
>>
>> Here's a Perl filter that will do the job.
>>
>> -Chris
>>
>> #!/usr/bin/env perl -0777 -nsw
>> # 
>> # Auth: Christopher Stone
>> # dCre: 2023/03/22 16:51
>> # dMod: 2023/03/22 16:51
>> # Task: Reformat Data for Use in a Database.
>> # Tags: @ccstone, @Shell, @Script, @Reformat, @Data, @Database
>> # 
>> use v5.12;
>>
>> $_ =~ s!\A\s+|\s+\Z!!g;
>>
>> my @recordArray = split(/\n\n/, $_);
>>
>> foreach my $record (@recordArray) {
>> my @record = split(/\n/, $record);
>> my $line1 = $record[0];
>> $line1 =~ s!^(.+)\h?-.+!$1!;
>> my $line2 = $record[1];
>> $line2 =~ s!^(\w+)\h.+!$1!;
>> my $prefix = $line1 . "\t" . $line2;
>> my $recordLength = scalar(@record) - 1;
>> my @newRecord = @record[2 .. $recordLength];
>>
>> foreach my $recordItem (@newRecord) {
>> say $prefix . "\t" . $recordItem;
>> }
>>
>> }
>>
>>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/0daa04c7-1ec6-404d-a257-6986494664ebn%40googlegroups.com.

Course Requests - Roster
Cherry Road Campus - 2023-2024
ART 200-2D Art IGrade 124
First Level RequestsGrade 108
Lastname, Firstname 10  Total   19
Lastname, Firstname 11
Lastname, Firstname 12
Lastname, Firstname 10
Lastname, Firstname 11
Lastname, Firstname 10
Lastname, Firstname 11
Lastname, Firstname 10
Lastname, Firstname 10
Lastname, Firstname 10
Lastname, Firstname 11
Lastname, Firstname 10
Lastname, Firstname 10
Lastname, Firstname 11
Grade 115
Grade 121
Grade 108
Total   14

ART 200-2D Art I
Alternate Request
Lastname, Firstname 11
Lastname, Firstname 11
Lastname, Firstname 10
Lastname, Firstname 10
Camarillo Lastname, Firstname   10
Lastname, Firstname 10
Lastname, Firstname 11
Lastname, Firstname 10
Lastname, Firstname 11
Lastname, Firstname 11
Lastname, Firstname 12
Lastname, Firstname 10
Lastname, Firstname 10
Lastname, Firstname 12
Lastname, Firstname 11
Lastname, Firstname 12
Lastname, Firstname 12
Lastname, Firstname 10
Lastname, Firstname 11
Female  30
Male3
Grade 117
Course Requests - Roster
Cherry Road Campus - 2023-2024
ART 215-2D Art Lastname, Firstname
First Level 

Re: Capturing multiple variables in regular expression

2023-03-23 Thread Doug Pinkerton
Wow. Problem resolved. The script is bulletproof.
Thanks very much to both of you. Your gracious expertise has saved me a lot 
of time.

dp

On Wednesday, March 22, 2023 at 4:58:07 PM UTC-5 Christopher Stone wrote:

> On Mar 22, 2023, at 10:40, Doug Pinkerton  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:
>
> --
>
> Hey Doug,
>
> Here's a Perl filter that will do the job.
>
> -Chris
>
> #!/usr/bin/env perl -0777 -nsw
> # 
> # Auth: Christopher Stone
> # dCre: 2023/03/22 16:51
> # dMod: 2023/03/22 16:51
> # Task: Reformat Data for Use in a Database.
> # Tags: @ccstone, @Shell, @Script, @Reformat, @Data, @Database
> # 
> use v5.12;
>
> $_ =~ s!\A\s+|\s+\Z!!g;
>
> my @recordArray = split(/\n\n/, $_);
>
> foreach my $record (@recordArray) {
> my @record = split(/\n/, $record);
> my $line1 = $record[0];
> $line1 =~ s!^(.+)\h?-.+!$1!;
> my $line2 = $record[1];
> $line2 =~ s!^(\w+)\h.+!$1!;
> my $prefix = $line1 . "\t" . $line2;
> my $recordLength = scalar(@record) - 1;
> my @newRecord = @record[2 .. $recordLength];
>
> foreach my $recordItem (@newRecord) {
> say $prefix . "\t" . $recordItem;
> }
>
> }
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/95dca53c-3b4f-4fa4-9482-12e1f2c85a30n%40googlegroups.com.


Re: Displaying TSV files

2023-03-23 Thread Greg Raven
I may be missing something, but when I need to do something along these 
lines I open in Numbers (or Excel), which allows an immediate visual 
confirmation of column integrity. 

On Friday, March 17, 2023 at 3:48:56 PM UTC-7 Laurel Cooper wrote:

> I work with large, tsv-formatted text files The files are 17 column text 
> files with the columns separated by tabs.  I need to be able to see that 
> none of the tabs are missing. 
> I can see the tab stops by turning on "Show invisibles", but in some lines 
> the tabs are basically on top of each other, and in other places, the text 
> is on top of them.  
> Is there a better way to display these files? 
> I took a screen shot as an example:
> Thanks!
>
> [image: tsv.jpg]
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/393079df-9b5d-4b06-9825-2bd11d54ad63n%40googlegroups.com.


Re: Need help simplifying apple script with grep

2023-03-23 Thread Mathias
Chris, worked great, you're the best. Thanks!

måndag 20 mars 2023 kl. 23:28:56 UTC+1 skrev Christopher Stone:

> On Mar 19, 2023, at 15:17, Mathias  wrote:
>
> OK folks, I feel like I'm nearly there, but I have a small outstanding 
> issue that perhaps you can find it in your heart to help me with.
>
> --
>
> Hey Mathias,
>
> What about something like this?
>
> ("[^"]+?") = "(.+?)";
>
>
> -Chris
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/968a48f6-85fe-4a28-8146-6789ef4cc819n%40googlegroups.com.