@@ -5,9 +5,53 @@ import (
55 "fmt"
66 "gocldf/csvw/dataset"
77 "os"
8- "strconv "
8+ "text/tabwriter "
99)
1010
11+ /*
12+ Type Rows
13+
14+ ----------------- ----------------- -------
15+ media.csv MediaTable 583
16+ examples.csv ExampleTable 94672
17+ languages.csv LanguageTable 42
18+ contributions.csv ContributionTable 42
19+ parameters.csv ParameterTable 335
20+ speakers.csv 289
21+ phones.csv 1863702
22+ words.csv 896664
23+ glosses.csv 2053
24+ sources.bib Sources 52
25+ */
26+ func stats (ds * dataset.Dataset ) {
27+ ds .LoadData ()
28+
29+ //fmt.Println(ds.MetadataPath)
30+ //fmt.Println(":")
31+ w := tabwriter .NewWriter (os .Stdout , 0 , 0 , 1 , ' ' , tabwriter .Debug )
32+ fmt .Fprintf (w , "%v\t %v\t %v\n " , "Filename" , "Component" , "Rows" )
33+ fmt .Fprintf (w , "%v\t %v\t %v\n " , "--------" , "---------" , "----" )
34+ for _ , table := range ds .Tables {
35+ cname := ""
36+ if table .Comp != "" {
37+ cname = table .CanonicalName ()
38+ }
39+ fmt .Fprintf (w , "%v\t %v\t %v\n " , table .Url , cname , len (table .Data ))
40+ /*
41+ fmt.Println(table.CanonicalName() + ": " + strconv.Itoa(len(table.Columns)) + " columns")
42+ for _, col := range table.Columns {
43+ fmt.Println(" " + col.CanonicalName())
44+ }
45+ fmt.Println(strconv.Itoa(len(table.Data)) + " rows")
46+ fmt.Println("ID of first item: ")
47+ fmt.Println(table.Data[0]["cldf_id"])
48+ fmt.Println("---")
49+
50+ */
51+ }
52+ w .Flush ()
53+ }
54+
1155func main () {
1256 flag .Usage = func () {
1357 fmt .Printf ("Usage: %s <CLDF metadata file>\n " , os .Args [0 ])
@@ -17,18 +61,5 @@ func main() {
1761 return
1862 }
1963 ds := dataset .New (os .Args [1 :][0 ])
20- ds .LoadData ()
21-
22- fmt .Println (ds .MetadataPath )
23- fmt .Println (":" )
24- for _ , table := range ds .Tables {
25- fmt .Println (table .CanonicalName () + ": " + strconv .Itoa (len (table .Columns )) + " columns" )
26- for _ , col := range table .Columns {
27- fmt .Println (" " + col .CanonicalName ())
28- }
29- fmt .Println (strconv .Itoa (len (table .Data )) + " rows" )
30- fmt .Println ("ID of first item: " )
31- fmt .Println (table .Data [0 ]["cldf_id" ])
32- fmt .Println ("---" )
33- }
64+ stats (ds )
3465}
0 commit comments