ADDED txtdb/nada3/sxml/_sheets.sxml Index: txtdb/nada3/sxml/_sheets.sxml ================================================================== --- /dev/null +++ txtdb/nada3/sxml/_sheets.sxml @@ -0,0 +1,59 @@ +((@ (http://www.w3.org/2001/XMLSchema-instance:schemaLocation + "http://www.gnumeric.org/v9.xsd")) + (http://www.gnumeric.org/v10.dtd:Version + (@ (Minor "17") (Major "10") (Full "1.10.17") (Epoch "1"))) + (http://www.gnumeric.org/v10.dtd:Attributes + (http://www.gnumeric.org/v10.dtd:Attribute + (http://www.gnumeric.org/v10.dtd:type "4") + (http://www.gnumeric.org/v10.dtd:name + "WorkbookView::show_horizontal_scrollbar") + (http://www.gnumeric.org/v10.dtd:value "TRUE")) + (http://www.gnumeric.org/v10.dtd:Attribute + (http://www.gnumeric.org/v10.dtd:type "4") + (http://www.gnumeric.org/v10.dtd:name + "WorkbookView::show_vertical_scrollbar") + (http://www.gnumeric.org/v10.dtd:value "TRUE")) + (http://www.gnumeric.org/v10.dtd:Attribute + (http://www.gnumeric.org/v10.dtd:type "4") + (http://www.gnumeric.org/v10.dtd:name "WorkbookView::show_notebook_tabs") + (http://www.gnumeric.org/v10.dtd:value "TRUE")) + (http://www.gnumeric.org/v10.dtd:Attribute + (http://www.gnumeric.org/v10.dtd:type "4") + (http://www.gnumeric.org/v10.dtd:name "WorkbookView::do_auto_completion") + (http://www.gnumeric.org/v10.dtd:value "TRUE")) + (http://www.gnumeric.org/v10.dtd:Attribute + (http://www.gnumeric.org/v10.dtd:type "4") + (http://www.gnumeric.org/v10.dtd:name "WorkbookView::is_protected") + (http://www.gnumeric.org/v10.dtd:value "FALSE"))) + (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document-meta + (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version "1.2")) + (urn:oasis:names:tc:opendocument:xmlns:office:1.0:meta + (http://purl.org/dc/elements/1.1/:date "2013-07-26T04:47:02Z") + (urn:oasis:names:tc:opendocument:xmlns:meta:1.0:creation-date + "2013-07-26T04:46:14Z"))) + (http://www.gnumeric.org/v10.dtd:Calculation + (@ (MaxIterations "100") + (ManualRecalc "0") + (IterationTolerance "0.001") + (FloatRadix "2") + (FloatDigits "53") + (EnableIteration "1"))) + (http://www.gnumeric.org/v10.dtd:SheetNameIndex + (http://www.gnumeric.org/v10.dtd:SheetName + (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") + (http://www.gnumeric.org/v10.dtd:Cols "256")) + "First_Sheet") + (http://www.gnumeric.org/v10.dtd:SheetName + (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") + (http://www.gnumeric.org/v10.dtd:Cols "256")) + "Second-sheet") + (http://www.gnumeric.org/v10.dtd:SheetName + (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") + (http://www.gnumeric.org/v10.dtd:Cols "256")) + "RunsToDo") + (http://www.gnumeric.org/v10.dtd:SheetName + (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") + (http://www.gnumeric.org/v10.dtd:Cols "256")) + "RunsToLock")) + (http://www.gnumeric.org/v10.dtd:Geometry (@ (Width "1440") (Height "647"))) + (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "1")))) ADDED txtdb/nada3/sxml/_workbook.sxml Index: txtdb/nada3/sxml/_workbook.sxml ================================================================== --- /dev/null +++ txtdb/nada3/sxml/_workbook.sxml @@ -0,0 +1,1 @@ +(*TOP* (*PI* xml "version=\"1.0\" encoding=\"UTF-8\"")) DELETED txtdb/nada3/sxml/sheets.sxml Index: txtdb/nada3/sxml/sheets.sxml ================================================================== --- txtdb/nada3/sxml/sheets.sxml +++ /dev/null @@ -1,59 +0,0 @@ -((@ (http://www.w3.org/2001/XMLSchema-instance:schemaLocation - "http://www.gnumeric.org/v9.xsd")) - (http://www.gnumeric.org/v10.dtd:Version - (@ (Minor "17") (Major "10") (Full "1.10.17") (Epoch "1"))) - (http://www.gnumeric.org/v10.dtd:Attributes - (http://www.gnumeric.org/v10.dtd:Attribute - (http://www.gnumeric.org/v10.dtd:type "4") - (http://www.gnumeric.org/v10.dtd:name - "WorkbookView::show_horizontal_scrollbar") - (http://www.gnumeric.org/v10.dtd:value "TRUE")) - (http://www.gnumeric.org/v10.dtd:Attribute - (http://www.gnumeric.org/v10.dtd:type "4") - (http://www.gnumeric.org/v10.dtd:name - "WorkbookView::show_vertical_scrollbar") - (http://www.gnumeric.org/v10.dtd:value "TRUE")) - (http://www.gnumeric.org/v10.dtd:Attribute - (http://www.gnumeric.org/v10.dtd:type "4") - (http://www.gnumeric.org/v10.dtd:name "WorkbookView::show_notebook_tabs") - (http://www.gnumeric.org/v10.dtd:value "TRUE")) - (http://www.gnumeric.org/v10.dtd:Attribute - (http://www.gnumeric.org/v10.dtd:type "4") - (http://www.gnumeric.org/v10.dtd:name "WorkbookView::do_auto_completion") - (http://www.gnumeric.org/v10.dtd:value "TRUE")) - (http://www.gnumeric.org/v10.dtd:Attribute - (http://www.gnumeric.org/v10.dtd:type "4") - (http://www.gnumeric.org/v10.dtd:name "WorkbookView::is_protected") - (http://www.gnumeric.org/v10.dtd:value "FALSE"))) - (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document-meta - (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version "1.2")) - (urn:oasis:names:tc:opendocument:xmlns:office:1.0:meta - (http://purl.org/dc/elements/1.1/:date "2013-07-26T04:47:02Z") - (urn:oasis:names:tc:opendocument:xmlns:meta:1.0:creation-date - "2013-07-26T04:46:14Z"))) - (http://www.gnumeric.org/v10.dtd:Calculation - (@ (MaxIterations "100") - (ManualRecalc "0") - (IterationTolerance "0.001") - (FloatRadix "2") - (FloatDigits "53") - (EnableIteration "1"))) - (http://www.gnumeric.org/v10.dtd:SheetNameIndex - (http://www.gnumeric.org/v10.dtd:SheetName - (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") - (http://www.gnumeric.org/v10.dtd:Cols "256")) - "First_Sheet") - (http://www.gnumeric.org/v10.dtd:SheetName - (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") - (http://www.gnumeric.org/v10.dtd:Cols "256")) - "Second-sheet") - (http://www.gnumeric.org/v10.dtd:SheetName - (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") - (http://www.gnumeric.org/v10.dtd:Cols "256")) - "RunsToDo") - (http://www.gnumeric.org/v10.dtd:SheetName - (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") - (http://www.gnumeric.org/v10.dtd:Cols "256")) - "RunsToLock")) - (http://www.gnumeric.org/v10.dtd:Geometry (@ (Width "1440") (Height "647"))) - (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "1")))) DELETED txtdb/nada3/sxml/workbook.sxml Index: txtdb/nada3/sxml/workbook.sxml ================================================================== --- txtdb/nada3/sxml/workbook.sxml +++ /dev/null @@ -1,1 +0,0 @@ -(*TOP* (*PI* xml "version=\"1.0\" encoding=\"UTF-8\"")) Index: txtdb/txtdb.scm ================================================================== --- txtdb/txtdb.scm +++ txtdb/txtdb.scm @@ -13,10 +13,12 @@ (use sxml-modifications) (use regex) (use srfi-69) (use regex-case) (use posix) +(use json) +(use csv) ;; Read a non-compressed gnumeric file (define (refdb:read-gnumeric-xml fname) (with-input-from-file fname (lambda () @@ -153,12 +155,12 @@ (sheets (find-section wrkbk 'http://www.gnumeric.org/v10.dtd:Sheets)) (sht-rem (remove-section wrkbk 'http://www.gnumeric.org/v10.dtd:Sheets)) (sheet-names (map (lambda (sheet) (sheet->refdb sheet targdir)) sheets))) - (sxml->file wrk-rem (conc targdir "/sxml/workbook.sxml")) - (sxml->file sht-rem (conc targdir "/sxml/sheets.sxml")) + (sxml->file wrk-rem (conc targdir "/sxml/_workbook.sxml")) + (sxml->file sht-rem (conc targdir "/sxml/_sheets.sxml")) (with-output-to-file (conc targdir "/sheet-names.cfg") (lambda () (map print sheet-names))))) (define (read-gnumeric-file fname) @@ -264,12 +266,12 @@ value))) (append rowdat coldat dat)))))) (define (refdb->sxml dbdir) (let* ((sht-names (read-file (conc dbdir "/sheet-names.cfg") read-line)) - (wrk-rem (file->sxml (conc dbdir "/sxml/workbook.sxml"))) - (sht-rem (file->sxml (conc dbdir "/sxml/sheets.sxml"))) + (wrk-rem (file->sxml (conc dbdir "/sxml/_workbook.sxml"))) + (sht-rem (file->sxml (conc dbdir "/sxml/_sheets.sxml"))) (sheets (fold (lambda (sheetname res) (let* ((sheetdat (read-dat (conc dbdir "/" sheetname ".dat"))) (cells (dat->cells sheetdat)) (sht-meta (file->sxml (conc dbdir "/sxml/" sheetname ".sxml")))) (cons (cons (car sht-meta) @@ -391,10 +393,20 @@ ;; (if (null? dat) ;; #f ;; (map cadr dat)))))) (define (edit-refdb path) + ;; TEMPORARY, REMOVE IN 2014 + (if (not (file-exists? (conc path "/sxml/_sheets.sxml"))) + (begin + (print "ERROR: You appear to have the old file structure for txtdb. Please do the following and try again.") + (print) + (print "mv " path "/sxml/sheets.sxml " path "/sxml/_sheets.sxml") + (print "mv " path "/sxml/workbook.sxml " path "/sxml/_workbook.sxml") + (print) + (print "Don't forget to remove the old files from your revision control system and add the new.") + (exit))) (let* ((dbname (pathname-strip-directory path)) (tmpf (conc (create-temporary-file dbname) ".gnumeric"))) (if (file-exists? (conc path "/sheet-names.cfg")) (refdb-export path tmpf)) (let ((pid (process-run "gnumeric" (list tmpf)))) @@ -436,10 +448,27 @@ (cond ((null? rema)(print help)) ((>= (length rema) 2) (apply process-action (car rema)(cdr rema))) (else (print help))))) + +;;====================================================================== +;; C R E A T E N E W D B S +;;====================================================================== + +(include "txtdb/metadat.scm") + +;; Creates a new db at path with one sheet +(define (create-new-db path) + (create-directory path #t) + (create-directory (conc path "/sxml") #t)) + ;; Sheet1.dat + ;; sheet-names.cfg + ;; sxml/Sheet1.sxml + ;; sxml/_sheets.sxml + ;; sxml/_workbook.sxml + (main) #| (define x (refdb:read-gnumeric-xml "testdata-stripped.xml"))