Vb.net 使用Lumenworks CSV解析器提取整行/行
使用LumenWorks CVS解析器时如何读取整行?到目前为止,我只能逐条读取,但不能读取整行。i、 如果一行是a、b、c、d、e、f,我就能读出每个字母表。但是,我希望能够阅读整行内容 目前我有:Vb.net 使用Lumenworks CSV解析器提取整行/行,vb.net,lumenworks,Vb.net,Lumenworks,使用LumenWorks CVS解析器时如何读取整行?到目前为止,我只能逐条读取,但不能读取整行。i、 如果一行是a、b、c、d、e、f,我就能读出每个字母表。但是,我希望能够阅读整行内容 目前我有: my_csv = New CsvReader(New StreamReader(file_path), False, ",", resetPoint) field_count = my_csv.FieldCount While my_csv.ReadNextRecord() 'proces
my_csv = New CsvReader(New StreamReader(file_path), False, ",", resetPoint)
field_count = my_csv.FieldCount
While my_csv.ReadNextRecord()
'process the data here
'This code will process each individual alphabet in one row
上面是每个字母表的读数。我想要的是
row=我的_csv.row
这个选项是可用的还是类似的
“编辑”
当你像我一样有基本的VB编程技能时,这就是你解决问题的方法
Dim my_string As String = ""
For x As Integer = 0 To my_csv.FieldCount - 1
my_string += my_csv(x).ToString.Trim + ","
Next
my_string = Mid(my_string, 1, Len(my_string) - 1)
Return my_string
务必使用标记答案中的代码。它非常优雅 我还没有找到任何可用的,但这应该可以: VB: C:
我发现了一种使用CopyCurrentRecordToarray方法的方法,该方法似乎比文件列越宽几秒钟要快一些: C: VB这是Telerik converter提供的,请注意:
Dim currentRow As String() = New String(csv.FieldCount - 1) {}
While csv.ReadNextRecord()
csv.CopyCurrentRecordTo(currentRow)
Dim line = String.Join(csv.Delimiter.ToString(), currentRow)
End While
谢谢现场工作。代码比我想出的更优雅。介意解释一下代码吗?我不懂选择功能。。。。
var rowFields = Enumerable.Range(0, my_csv.FieldCount)
.Select(field => my_csv[(int)my_csv.CurrentRecordIndex, field]);
string line = string.Join(my_csv.Delimiter.ToString(), rowFields);
string[] currentRow = new string[csv.FieldCount];
while (csv.ReadNextRecord())
{
csv.CopyCurrentRecordTo(currentRow);
var line = string.Join(csv.Delimiter.ToString(), currentRow);
}
Dim currentRow As String() = New String(csv.FieldCount - 1) {}
While csv.ReadNextRecord()
csv.CopyCurrentRecordTo(currentRow)
Dim line = String.Join(csv.Delimiter.ToString(), currentRow)
End While