Vb.net 如何在Visual Basic中分析不同行之间的CSV条目?
具有以下CSV文件Vb.net 如何在Visual Basic中分析不同行之间的CSV条目?,vb.net,winforms,csv,Vb.net,Winforms,Csv,具有以下CSV文件 Number;Name;Description;Assessment;Result;Other_fields 101;Entity0001;Participant;Not_Qualified;;; 101;Entity0003;Participant;Qualified;10000;; 101;Entity0004;Participant;Qualified;8000;yes; 101;Entity0006;Participant;Qualified;12000,5;;
Number;Name;Description;Assessment;Result;Other_fields
101;Entity0001;Participant;Not_Qualified;;;
101;Entity0003;Participant;Qualified;10000;;
101;Entity0004;Participant;Qualified;8000;yes;
101;Entity0006;Participant;Qualified;12000,5;;
111;Entity0112;Participant;Qualified;100;;
111;Entity0113;Participant;Not_Qualified;120,5;;
111;Entity0110;Participant;Qualified;100;yes;
我想像这样分析:在同一个项目中,从上面的示例项目的“数字”可以等于101或111,这是什么
-所有结果中的最小结果/最大结果;
-其次是最低限度的结果;
-不同“结果”之间的差异百分比,
等等我希望我能够添加一次计算,如果我不理解如何在行之间比较条目的原则
使用用于CSV的标准Microsoft dev工具,可以按如下方式对行(行)中的条目进行打包:
Using MyReader As New Microsoft.VisualBasic.
FileIO.TextFieldParser(
"C:\Users\ ... path... \test2.txt")
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(";")
Dim currentRow As String()
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
'### Columns of interest in txt (csv) file ####
Dim NUMBER = currentRow(0)
Dim RESULT = currentRow(4)
'### Entries can be parced into variables
'from cvs lines and converted to numbers for math###
Dim NUMBER_OF_LINE As Integer
NUMBER_OF_LINE = CInt(MyReader.LineNumber)
Dim NUMBER_CONVERTED As Integer
Dim RESULT_CONVERTED As Decimal
If RESULT <> "" Then
If RESULT <> "Result" Then
RESULT_CONVERTED = CDec(RESULT)
End If
End If
If NUMBER <> "" Then
If NUMBER <> "Number" Then
NUMBER_CONVERTED = CInt(NUMBER)
End If
End If
'### And then Written to File - omitted ###
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message &
"is not valid and will be skipped.")
End Try
End while
"输出省略,
请更聪明的人帮忙:我需要什么样的循环(循环),以及如何实现它,以便能够计算(见上文)位于不同行/行上的部分条目 我不明白数字是如何发挥作用的,但似乎你需要收集所有的结果值,这样你才能进行计算。我猜它们是十进制或双精度的,所以首先创建一个列表(T),在读取文件时收集它们。数字是否作为一个分区?要计算101的一组结果和100的另一组结果吗?如果是这样,则需要收集两组结果值
Number of line: 2 Converted number: 0 Converted result: 0
Number of line: 3 Converted number: 101 Converted result: 0
Number of line: 4 Converted number: 101 Converted result: 10000
Number of line: 5 Converted number: 101 Converted result: 8000
Number of line: 6 Converted number: 101 Converted result: 12000,5