/// <summary> /// Returns width of columns. /// </summary> private ColumnInfo[] ParseColumns(string headerLine, string columnWidthLine) { string[] widths = columnWidthLine.Split(' '); int count = widths.Length - 1; ColumnInfo[] columns = new ColumnInfo[count]; int pos = 0; for (int i = 0; i < count; i++) { int width = widths[i].Length; columns[i] = new ColumnInfo(); columns[i].Title = headerLine.Substring(pos, width).Trim(); columns[i].Width = width; columns[i].Position = pos; pos += width + 1; } return columns; }
/// <summary> /// Replace spaces between columns to TABs. /// </summary> private string MakeTSVLine(ColumnInfo[] columns, string headerLine) { StringBuilder tsvLine = new StringBuilder(); foreach (ColumnInfo column in columns) { if (tsvLine.Length != 0) { tsvLine.Append('\t'); } tsvLine.Append(headerLine.Substring(column.Position, column.Width)); } return tsvLine.ToString(); }