Hi Howard, here's a NodeJS version
Put the following in a file named "converter.js"
To run in Terminal: node path/to/converter.js path/to/source
fs = require("fs"); //Load two npm packages
path = require("path");
sourcePath = process.argv[2]; //Set filepaths
formattedPath = path.join(path.dirname(sourcePath), path.parse(sourcePath).name
+ "-Formatted" + path.extname(sourcePath));
talliedPath = path.join(path.dirname(sourcePath), path.parse(sourcePath).name +
"-Tallied" + path.extname(sourcePath));
nameTally = {};
content = fs.readFileSync(sourcePath).toString().trim().split("\n\n"); //get,
process, and write formatted content
content.forEach((thisEntry, entryCount) => {
thisEntry = thisEntry.split("\n");
let thisName = thisEntry[0];
nameTally[thisName] = nameTally[thisName] ? nameTally[thisName] + 1 : 1;
content[entryCount] = thisEntry.join(" -- ");
});
fs.writeFileSync(formattedPath, content.join("\n"));
nameTallyOutput = []; //prep & write the nameTally file
for (thisName in nameTally) content.push(thisName + ": " + nameTally[thisName]);
fs.writeFileSync(talliedPath, content.join("\n"));
> On Sep 8, 2021, at 8:05 AM, Howard <[email protected]> wrote:
>
> I have multiple instances of this sample data (below) in which each
> observation has at least three lines and is separated by a blank line. In
> each observation, the first line contains a name, the second a time, and then
> there is one or more lines of text:
>
> SAMPLE DATA
> Peter Frost
> 25:34
> yes
>
> Elle Claus
> 30:05
> Third line
>
> Elle Claus
> 30:25
> Third line
> Fourth line
>
> Cary Clark
> 31:21
> done
> ________________
> First, I would like the data organized so that each observation's lines are
> combined and separated by two dashes:
>
> SAMPLE COMBINED DATA
> Peter Frost -- 25:34 -- yes
> Elle Claus -- 30:05 -- Third line
> Elle Claus -- 30:25 -- Third line -- Fourth line
> Cary Clark -- 31:21 -- done
> ________________
> Then, I would like a count of the observations by name:
>
> SAMPLE COUNTED DATA
> Peter Frost 1
> Elle Claus 2
> Cary Clark 1
>
> I am familiar with using Unix command solutions.
>
> Thanks,
> Howard
>
> --
> 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 <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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/89eb8047-72c1-4d21-b46d-fa9ad0225425n%40googlegroups.com
>
> <https://groups.google.com/d/msgid/bbedit/89eb8047-72c1-4d21-b46d-fa9ad0225425n%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/E6CECBE9-5A82-42B7-AA3D-11109E0FBABE%40gmail.com.