Index: in/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/CLEAN.sh
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/CLEAN.sh	(revision 34490)
+++ 	(revision )
@@ -1,4 +1,0 @@
-#!/bin/bash
-
-mvn clean
-
Index: in/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/COMPILE.sh
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/COMPILE.sh	(revision 34490)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!/bin/bash
-
-mvn compile assembly:single 
Index: /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/CLEAN.sh
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/CLEAN.sh	(revision 34491)
+++ /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/CLEAN.sh	(revision 34491)
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+mvn clean
+
Index: /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/COMPILE.sh
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/COMPILE.sh	(revision 34491)
+++ /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/COMPILE.sh	(revision 34491)
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+mvn compile assembly:single 
Index: /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/RUN.sh
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/RUN.sh	(revision 34491)
+++ /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/RUN.sh	(revision 34491)
@@ -0,0 +1,5 @@
+
+#cd target \
+#   && java -cp waikato-independent-db-1.0-SNAPSHOT.jar org.greenstone.accessdb.App
+
+java -jar target/waikato-independent-db-1.0-SNAPSHOT-jar-with-dependencies.jar
Index: /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/main/java/org/greenstone/accessdb/TableToCSV.java
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/main/java/org/greenstone/accessdb/TableToCSV.java	(revision 34491)
+++ /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/main/java/org/greenstone/accessdb/TableToCSV.java	(revision 34491)
@@ -0,0 +1,196 @@
+package org.greenstone.accessdb;
+ 
+import java.sql.*;
+import java.io.OutputStreamWriter;
+
+public class TableToCSV
+{
+    
+    final static String TABLE_NAME = "WAIKATO_INDEPENDENT";
+    
+    public static void printDatabaseMetadata(Connection connection)
+    {
+        try {
+
+	    System.out.println("----");
+	    System.out.println("Database Table Names");
+	    System.out.println("----");
+            DatabaseMetaData dbmd = connection.getMetaData();
+            String[] types = {"TABLE"};
+            ResultSet rs = dbmd.getTables(null, null, "%", types);
+            while (rs.next()) {
+                System.out.println(rs.getString("TABLE_NAME"));
+            }
+	    System.out.println("----");
+        } 
+            catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void printTable(Connection connection, String table_name)
+    {
+	try {
+	    Statement st = connection.createStatement();
+	    ResultSet rs = st.executeQuery("SELECT * from " + table_name);
+	    ResultSetMetaData rsmd = rs.getMetaData();
+	    
+	    int columnsNumber = rsmd.getColumnCount();                     
+	    
+	    // Iterate through the data in the result set and display it. 
+	    System.out.println("----");
+	    System.out.println("Table: " + table_name);
+	    System.out.println("----");
+
+	    for(int i = 1; i <= columnsNumber; i++) {
+		System.out.print(rsmd.getColumnLabel(i)+ "|");
+	    }
+	    System.out.println();
+	    
+	    while (rs.next()) {
+		for(int i = 1 ; i <= columnsNumber; i++){
+		    System.out.print(rs.getString(i));
+		    if (i != columnsNumber) { System.out.print(","); }
+		}
+		
+		System.out.println();
+	    
+	    }
+	    	
+	    System.out.println("----");
+	    
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}
+	
+    }
+
+
+    public static void accessTableToCSVFile(Connection connection, String table_name, String csv_filename)
+    {
+	try {
+	    Statement st = connection.createStatement();
+	    ResultSet rs = st.executeQuery("SELECT * from " + table_name);
+	    ResultSetMetaData rsmd = rs.getMetaData();
+	    
+	    int columnsNumber = rsmd.getColumnCount();                     
+
+	    System.out.println("Converting MS Access Database Table '" + table_name + "' to CSV file: " + csv_filename);
+	    
+	    OutputStreamWriter csv_osw = UtilIO.openTextFile(csv_filename);
+
+	    if (csv_osw != null) {
+		
+		for (int i=1; i<=columnsNumber; i++) {
+		    String heading = rsmd.getColumnLabel(i);
+		    String heading_safe = heading;
+
+		    if (heading_safe != null) {
+			UtilIO.appendTextToFile(csv_osw,heading_safe);
+		    }
+
+		    if (i < columnsNumber) { UtilIO.appendTextToFile(csv_osw,","); }
+		    
+		}
+		UtilIO.appendTextToFile(csv_osw,"\n");
+
+		
+		int line_count = 0;
+		
+		while (rs.next()) {
+		    for (int i=1 ; i<=columnsNumber; i++){
+			String val = rs.getString(i);
+			
+			if (val != null) {
+
+			    int val_len = val.length();
+			    
+			    //if ((val_len>=2) && ((val.charAt(0) == '"') && (val.charAt(val_len-1) == '"'))) {
+			    //val = val.substring(1,val_len-2);
+			    //}
+			
+			    String val_safe = val.replaceAll(",","\\\\,").replaceAll("\"","\\\\\"");
+
+			    UtilIO.appendTextToFile(csv_osw,'"'+val_safe+'"');
+			}
+			
+			if (i < columnsNumber) { UtilIO.appendTextToFile(csv_osw,","); }
+		    }
+
+		    UtilIO.appendTextToFile(csv_osw,"\n");		    
+
+		    line_count++;
+		    if ((line_count % 1000) == 0) {
+			System.out.println("Processed lines " + (line_count - 999) + "-" + line_count);
+		    }
+		}
+		
+		
+		UtilIO.closeTextFile(csv_osw);
+		
+	    }	    
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}
+	
+    }
+
+    public static void main( String[] args )
+    {
+         
+        //String databaseURL = "jdbc:ucanaccess://d:/cygwin64/home/davidb/research/code-unmanaged/cambridge-museum/waikato-independent-db/Waikato Independent.accdb";
+	String databaseURL = "jdbc:ucanaccess://Waikato Independent.accdb";
+		
+	System.out.println("Opening: '" + databaseURL + "' ...");
+	
+        try (Connection connection = DriverManager.getConnection(databaseURL)) {
+	    System.out.println("... connnected");
+
+	    printDatabaseMetadata(connection);
+
+	    System.out.println();
+
+	    //printTable(connection, TABLE_NAME);
+		
+	    String csv_filename = TABLE_NAME + ".csv";
+	    
+	    accessTableToCSVFile(connection, TABLE_NAME, csv_filename);
+
+	    
+	    /*
+            String sql = "INSERT INTO Contacts (Full_Name, Email, Phone) VALUES (?, ?, ?)";
+             
+            PreparedStatement preparedStatement = connection.prepareStatement(sql);
+            preparedStatement.setString(1, "Jim Rohn");
+            preparedStatement.setString(2, "rohnj@herbalife.com");
+            preparedStatement.setString(3, "0919989998");
+             
+            int row = preparedStatement.executeUpdate();
+             
+            if (row > 0) {
+                System.out.println("A row has been inserted successfully.");
+            }
+             
+            sql = "SELECT * FROM Contacts";
+             
+            Statement statement = connection.createStatement();
+            ResultSet result = statement.executeQuery(sql);
+             
+            while (result.next()) {
+                int id = result.getInt("Contact_ID");
+                String fullname = result.getString("Full_Name");
+                String email = result.getString("Email");
+                String phone = result.getString("Phone");
+                 
+                System.out.println(id + ", " + fullname + ", " + email + ", " + phone);
+            }
+	    */
+	    
+        } catch (SQLException ex) {
+            ex.printStackTrace();
+        }
+    }
+}
+
Index: /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/main/java/org/greenstone/accessdb/UtilIO.java
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/main/java/org/greenstone/accessdb/UtilIO.java	(revision 34491)
+++ /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/main/java/org/greenstone/accessdb/UtilIO.java	(revision 34491)
@@ -0,0 +1,118 @@
+package org.greenstone.accessdb;
+
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+
+
+public class UtilIO {
+    public enum CaseProcessing { AsIs, ToLower }
+	
+    // LRL = Low-Resource Language
+    public final static String LRL_HOME = "d:\\cygwin64\\home\\davidb\\research\\code-managed\\hathitrust\\HTRC-Lowres-Lang-Detect"; 
+	
+    public static ArrayList<String> readLineBasedTextFile(String input_filename, CaseProcessing case_mode) 
+    {
+	ArrayList<String> text_lines = new ArrayList<String>();
+		
+	try {
+	    File fileDir = new File(input_filename);
+
+	    FileInputStream fis = new FileInputStream(fileDir);
+	    InputStreamReader isr = new InputStreamReader(fis, "UTF8");
+	    BufferedReader brin = new BufferedReader(isr);
+		
+	    String intput_line;
+	    while ((intput_line = brin.readLine()) != null) {
+		if (case_mode == CaseProcessing.ToLower) {
+		    intput_line = intput_line.toLowerCase();
+		}
+		text_lines.add(intput_line);
+	    }
+
+	    brin.close();
+	} 
+	catch (Exception e)  {
+	    e.printStackTrace();
+	}
+		
+	return text_lines;
+    }
+	
+    public static ArrayList<String> readLineBasedTextFile(String input_filename) 
+    {
+	return readLineBasedTextFile(input_filename, CaseProcessing.AsIs);
+    }
+	
+    public static String readTextFile(String input_filename)
+    {
+	ArrayList<String> text_lines = readLineBasedTextFile(input_filename);
+		
+	String text = String.join("\n", text_lines);
+		
+	return text;
+    }
+			
+	
+    public static void writeTextToFile(String output_filename, String text) 
+    {
+	// try-resource syntax auto-closes stream
+	try (FileOutputStream fos = new FileOutputStream(output_filename)) {
+	    OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
+	    osw.write(text);
+	    osw.close();
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}				
+    }
+
+
+
+    public static OutputStreamWriter openTextFile(String output_filename) 
+    {
+	OutputStreamWriter osw = null;
+		    
+	try {
+	    FileOutputStream fos = new FileOutputStream(output_filename);
+	    osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}
+
+	return osw;
+    }
+    
+    public static void appendTextToFile(OutputStreamWriter osw, String text) 
+    {
+	try {
+	    osw.write(text);
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}				
+    }
+
+    public static void closeTextFile(OutputStreamWriter osw) 
+    {
+
+	try {
+	    osw.close();
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}				
+    }
+
+    
+	
+}
Index: /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/test/java/org/greenstone/accessdb/AppTest.java
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/test/java/org/greenstone/accessdb/AppTest.java	(revision 34491)
+++ /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/MSAccessToCSV/src/test/java/org/greenstone/accessdb/AppTest.java	(revision 34491)
@@ -0,0 +1,20 @@
+package org.greenstone.accessdb;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+{
+    /**
+     * Rigorous Test :-)
+     */
+    @Test
+    public void shouldAnswerWithTrue()
+    {
+        assertTrue( true );
+    }
+}
Index: in/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/RUN.sh
===================================================================
--- /main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/RUN.sh	(revision 34490)
+++ 	(revision )
@@ -1,5 +1,0 @@
-
-#cd target \
-#   && java -cp waikato-independent-db-1.0-SNAPSHOT.jar org.greenstone.accessdb.App
-
-java -jar target/waikato-independent-db-1.0-SNAPSHOT-jar-with-dependencies.jar
