Commits

tbrugz committed 15235e8

sqlrun/importer: record delimiter now a regex pattern (\r?\n)

Comments (0)

Files changed (2)

sqlrun.template.properties

 sqlrun.exec.80.importfile=${basedir}/file1.csv
 # output appended data as the file grows - inspired by 'tail -f'
 sqlrun.exec.80.follow=true|false
-# default recorddelimiter: "\n"
+# default recorddelimiter: "\r?\n" (regex)
 sqlrun.exec.80.recorddelimiter=\r\n
 sqlrun.exec.80.columndelimiter=;
 sqlrun.exec.80.encoding=ISO-8859-1

src_run/tbrugz/sqldump/sqlrun/importers/AbstractImporter.java

 	String importDir = null;
 	String importFiles = null;
 	boolean follow = false;
-	String recordDelimiter = "\n";
+	String recordDelimiter = "\r?\n";
 	String insertTable = null;
 	String insertSQL = null;
 	String inputEncoding = "UTF-8";
 					mustSetupSQLStatement = true;
 				}
 				String line = scan.next();
+				/*if(line.endsWith(recordDelimiter)) {
+					log.info("line1["+line.length()+"]: ["+line+"]");
+					line = line.substring(0,line.length()-recordDelimiter.length()-1);
+					log.info("line2["+line.length()+"]: ["+line+"]");
+				}*/
 				
 				while(importthisline) {
 					try {
 			scan = new Scanner(fileIS, inputEncoding);
 			//scan = new Scanner(new File(importFile), inputEncoding);
 		}
-		scan.useDelimiter(Pattern.quote(recordDelimiter));
+		scan.useDelimiter(recordDelimiter);
 		return scan;
 	}