public override void ExitRow([NotNull] CSVParser.RowContext context) { //skip header if (context.col == 0) { return; } index++; var separator = context.children.Count(x => x.GetText().Equals(";")); //riga vuota if (context.fields == 0) { LogRows.Add(new KeyValuePair <int, string>(index, "Riga vuota")); r.Delete(context.start, context.stop); } //separatori in eccesso a fine riga else if (separator >= context.fields) { LogRows.Add(new KeyValuePair <int, string>(index, "Separatori in eccesso alla fine della riga")); //cancello i separatori in eccesso alla fine della riga for (int i = context.fields; i <= separator; i++) { r.Delete(context.SEP(i - 1).Symbol); } } else if (separator < context.col - 1) { shortRows = true; LogRows.Add(new KeyValuePair <int, string>(index, "Riga troppo corta")); } }
public override void EnterRow(CSVParser.RowContext context) { if (_isHeader) { return; } Records.Add(new Dictionary <string, string>()); }
public override ParserNode VisitRow(CSVParser.RowContext context) { var node = GetNode(context, ROW, ParserNode.ParserNavigationTypeEnum.FirstChild); if (node.Start == node.End) { return(null); } foreach (var cell in context.cell()) { Visit(cell).Parent = node; } return(node); }
public DataItem VisitRow(List <string> names, CSVParser.RowContext context) { DataObject item = new DataObject(); if (names.Count != context.field().Length) { throw new Exception("Wrong number of elements"); } for (int a = 0; a < names.Count; a++) { item.AddField(names[a], new DataValue() { Text = CleanField(context.field()[a].GetText()) }); } return(item); }
/// <summary> /// Exit a parse tree produced by <see cref="CSVParser.row"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitRow([NotNull] CSVParser.RowContext context) { }