开发者

merge and match two csv files with .net

开发者 https://www.devze.com 2023-01-22 19:49 出处:网络
i\'ve got two csv files that i want to merge. Basically, i\'ve got my source file, and the second file will add information to that file using a primary key that they both share.

i've got two csv files that i want to merge. Basically, i've got my source file, and the second file will add information to that file using a primary key that they both share.

I've done this using v-lookup but since this will be a weekly process,开发者_高级运维 i want to automate it using vb.net or C#. any ideas?

Thanks


It is quite possible to use SQL with CSV files in either vb.net or c#.

Some notes:

cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=c:\docs\;" & _
            "Extended Properties=""text;HDR=Yes;FMT=Delimited"""
cn.Open()

cmd.Connection = cn
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT a.PK, b.SText,a.[Processor Time] INTO BookX.csv " & _
            "FROM [Book1.CSV] a " & _
            "LEFT JOIN [Book2.CSV] b " & _
            "ON a.PK = b.PK"
0

精彩评论

暂无评论...
验证码 换一张
取 消