我有一个csv文件,我想要获取列中的所有值,并将其存储在字符串列表中。
我的csv部分内容如下:
物料ID |价格|到货时间
14/09-7 | 35.9 |2014/9/7
14/09-8 | 6.45 |2014/9/7
14/09-9 | 7.1 |2014/9/7
14/09-10 | 4.75 |2014/9/7
14/09-11 |4| 9/7/2014
14-09-12| 6.1 |2014-9-7
14-09-13| 5.3 |2014-9-7
我想在字符串列表中得到的结果是:
"14/09-7,14/09-8,14/09-9,14/09-10,14/09-11,14/09-12,14/09-13“
我还没有找到合适的例子。对此有什么建议吗?我正在使用vb.net(vs2012)。
发布于 2014-10-23 10:44:21
假设您想要的行从第二行开始,您可以尝试这样做:
Public Function GetList(ByVal fileName As String) As List(Of String)
Dim reader As New StreamReader(fileName)
Dim line As String = Nothing
Dim index As Integer = 0
Dim list As New List(Of String)
While (reader.Peek() <> -1)
line = reader.ReadLine()
If index > 0 Then
Try
list.Add(line.Split("\\|")(0))
Catch ex As Exception
'exception handler
End Try
End If
index += 1
End While
Return list
End Functionhttps://stackoverflow.com/questions/26520317
复制相似问题