the parallels JSON in sc-data might as well as be greek to me
Can someone tell me how I can extract a list of the pali suttas in order with just the whole of sutta parallels listed after each pali sutta and outputed into a list I could open in sheets?
any help or suggestions appreciated.
I wrote up a quick little go script to handle this. You can download the go compiler here.
Save the following to parallels2csv.go
, run go build parallels2csv.go
. Then run the following command parallels2csv parallels.json > parallels.csv
. parallels.json is downloaded from sc-data. This should work on MacOS, Linux, and Windows. You can open the CSV in sheets.
Not sure this is exactly what you’re looking for but it should be a good start. I am not invested in this script so don’t expect much support on it.
package main
import (
"encoding/json"
"fmt"
"log"
"os"
)
type JsonData struct {
P []string `json:"parallels"`
}
func main() {
rawData, err := os.ReadFile(os.Args[1])
if err != nil {
log.Fatal(err)
}
var jsonData []JsonData
err = json.Unmarshal(rawData, &jsonData)
if err != nil {
log.Fatal(err)
}
maxLen := 0
for _, d := range jsonData {
maxLen = max(maxLen, len(d.P))
}
for i := range maxLen {
fmt.Printf("parallel %d,", i+1)
}
fmt.Println()
for _, d := range jsonData {
for _, p := range d.P {
fmt.Printf("%q,", p)
}
if maxLen-len(d.P) > 0 {
for range maxLen - len(d.P) {
fmt.Printf(",")
}
}
fmt.Println()
}
}
2 Likes
thats amazing! ummm can you just run it an PM me the csv? I am pretty hopeless with compilers and so on, I’ve just switched form linux to windows 11 and I feel like i dont know anything!
(like trying to find a way to select all below the cursor to the end of file, i used to know how to do that i am sure of it.)
anyway, thanks for that! I will endeavor to figure it out