我正在比较两张桌子。我将获得在另一个表中找不到的行,并计算所有可能的行。 应将此信息报告在具有良好概述的文件中。 我从文件中读取了表格!像CSV一样,但它们是文本文件。
我的表类:
class TableModel {
private string tableName;
private string[] headers;
private string[] keys;
public int HeaderCount { get; set; }
public int RowCount { get; set; }
public string TableName { get { return tableName; } set { this.tableName = value; } }
public string[] Headers { get { return headers; } set { this.headers = value; } }
public string[] Keys { get { return keys; } set { this.keys = value; } }
}
我的TableLoader:
class TableLoader {
public TableModel LoadTable(string path) {
TableModel model = new TableModel();
FileStream filestream = new FileStream(path, FileMode.Open, FileAccess.Read);
using(StreamReader reader = new StreamReader(filestream, Encoding.UTF8)){
string line = "";
bool isHeader = true;
int index = 0;
model.RowCount = File.ReadAllLines(path).Length;
string[] rows = new string[model.RowCount-1];
while ((line = reader.ReadLine()) != null) {
if (isHeader) {
model.Headers = line.Split(new string[]{"\t"}, StringSplitOptions.RemoveEmptyEntries);
isHeader = false;
continue;
}
rows[index] = line;
index++;
}
model.HeaderCount = model.Headers.Length;
model.Keys = rows;
}
return model;
}
}
我的比较课程: 只是想知道我想做什么。
class Compare {
//Tables CURRENT | NEW
TableModel newModel;
TableModel currentModel;
string dirName;
//REPORT.txt
private static string report;
//Contents
HashSet<string> currentContent;
HashSet<string> newContent;
//Headers
HashSet<string> headersNotFoundInC = new HashSet<string>();
HashSet<string> headersNotFoundInN = new HashSet<string>();
private bool headerSequence = false;
//Rows
HashSet<string> rowNotFoundInC = new HashSet<string>();
HashSet<string> rowNotFoundInN = new HashSet<string>();
//Constructor
public Compare(TableModel newModel, TableModel currentModel, string dirName) {
this.newModel = newModel;
this.currentModel = currentModel;
this.dirName = dirName;
StartCompare();
CreateReportFile();
}
//METHODS
private void CreateReportFile() {
}
private void StartCompare() {
}
public void checkHeaders() {
}
public void checkRows() {
}
public void ShowNotFoundHeaders() {
}
public void ShowNotFoundRows() {
}
public void CheckHeaderCount() {
}
public void CheckRowCount() {
}
public void ReportHeaders() {
}
public void ReportRows() {
}
public void SetTitle(string title) {
}
}