<commit_before>package durbin.util;


/***********************************
* Support for accessing a table one row at a time, accessing
* fields by name.  
* 
*  new OnlineTable(fileName).eachRow{row->
*		println row.name
*   println row.address
* }
* 
*/
class OnlineTable{			

	String fileName
	String sep = null;
	
	def row

	def OnlineTable(String f,String delimiter){
		fileName = f
		sep = delimiter
	}

	def OnlineTable(String f){
		sep = FileUtils.determineSeparator(f)
		fileName = f
	}			

	def eachRow(Closure c){
		new File(fileName).withReader{r->
			def headingStr = r.readLine()
			def headings = headingStr.split(sep,-1)
			r.eachLine{rowStr->
				def rfields = rowStr.split(sep,-1)
				row = [:]
				rfields.eachWithIndex{f,i->row[headings[i]]=f}
				c(row)
			}
		}
	}	
	
	def headings(){
		return(row.keySet())
	}
	
}<commit_msg>Improved header support of OnlineTable<commit_after>package durbin.util;


/***********************************
* Support for accessing a table one row at a time, accessing
* fields by name.  
* 
*  new OnlineTable(fileName).eachRow{row->
*		println row.name
*   println row.address
* }
* 
*/
class OnlineTable{			

	String fileName
	String sep = null;
	
	def headings
	def row

	def OnlineTable(String f,String delimiter){
		fileName = f
		sep = delimiter		
		new File(fileNAme).withReader{r->
			def headingStr = r.readLine()
			headings = headingStr.split(sep,-1)
		}

	}

	def OnlineTable(String f){
		sep = FileUtils.determineSeparator(f)a
		fileName = f
	}			

	def eachRow(Closure c){
		new File(fileName).withReader{r->
			def temp = r.readLine() // consume header.
			r.eachLine{rowStr->
				def rfields = rowStr.split(sep,-1)
				row = [:]
				rfields.eachWithIndex{f,i->row[headings[i]]=f}
				c(row)
			}
		}
	}	
	
	def headings(){
		return(headings)
	}	
}
{'fraction_non_alphanumeric': 0.16024229074889867, 'fraction_numerical': 0.0022026431718061676, 'mean_word_length': 3.315914489311164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1192880', 'n_tokens_mistral': 740, 'n_tokens_neox': 650, 'n_words': 146}