从csv txt文件构建数组 [英] Building an array from a csv txt file

查看:68
本文介绍了从csv txt文件构建数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮助,脑死了,需要从csv txt

文件构建一个多dem阵列,只需指向一篇好文章,我相信旧的灰质会做

a doh!。

Help, went brain dead here, need to build a multi dem array from a csv txt
file, just point to a good article and I am sure the old gray matter will do
a doh!.

推荐答案

James,


构建数组(列表)是一些工作,因为你必须制作对象

和循环,使数据集是一块蛋糕。


私有子Form1_Load(ByVal发送者为对象,_

ByVal e As System.EventArgs)处理MyBase.Load

Dim file As String =" Test2.txt"

Dim path As String =" C:\ Test1 \"

Dim ds As New DataSet

尝试

Dim f As System.IO .File

如果f.Exists(路径和文件)那么

Dim ConStr As String = _

" Provider = Microsoft.Jet .OLEDB.4.0;数据源=" &安培; _

路径& " ;; Extended Properties ="" Text; HDR = No; FMT = Delimited\""

Dim conn As New OleDb.OleDbConnection(ConStr)

Dim da As New OleDb.OleDbDataAdapter(" Select * from"& _

file,conn)

da.Fill(ds," TextFile" ;)

结束如果

Catch ex As Exception

MessageBox.Show(ex.ToString)

结束尝试

DataGrid1.DataSource = ds.Tables(0)

结束子

///


我希望这有帮助吗?


Cor
James,

Building an array(list) is some work because you would have to make objects
and a loop, making a dataset is a piece of cake.

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
///

I hope this helps?

Cor


James,


建立一个array(list)是一些工作,因为你必须制作对象

和一个循环,使数据集是小菜一碟。


Private Sub Form1_Load (ByVal sender As Object,_

ByVal e As System.EventArgs)Handles MyBase.Load

Dim file As String =" Test2.txt"

Dim path As String =" C:\ Test1 \"

D im ds As New DataSet

尝试

Dim f As System.IO.File

如果f.Exists(路径&然后

Dim ConStr As String = _

" Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" &安培; _

路径& " ;; Extended Properties ="" Text; HDR = No; FMT = Delimited\""

Dim conn As New OleDb.OleDbConnection(ConStr)

Dim da As New OleDb.OleDbDataAdapter(" Select * from"& _

file,conn)

da.Fill(ds," TextFile" ;)

结束如果

Catch ex As Exception

MessageBox.Show(ex.ToString)

结束尝试

DataGrid1.DataSource = ds.Tables(0)

结束子

///


我希望这有帮助吗?


Cor
James,

Building an array(list) is some work because you would have to make objects
and a loop, making a dataset is a piece of cake.

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
///

I hope this helps?

Cor


将文件转储成字符串,然后使用Split构建数组


hth guy


" James D. Marshall"写道:
Dump the file into a string and then use Split to build your array

hth guy

"James D. Marshall" wrote:
帮助,脑死了这里,需要从csv txt
文件构建一个多dem阵列,只需指向一篇好文章,我肯定老了灰质会怎么做!
Help, went brain dead here, need to build a multi dem array from a csv txt
file, just point to a good article and I am sure the old gray matter will do
a doh!.



这篇关于从csv txt文件构建数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆