如何在vb.net中将列值写入行 [英] How to write column values into a row in vb.net

查看:80
本文介绍了如何在vb.net中将列值写入行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的文件

I have a file like this

No,Name,class,Marks
1,George,4,65
1,George,4,35
1,George,4,72
1,George,4,65
1,George,4,56
1,George,4,64
1,George,4,43
2,Martin,4,54
2,Martin,4,76
2,Martin,4,23
2,Martin,4,97
2,Martin,4,65
2,Martin,4,43
2,Martin,4,76



我的输出文件应如下所示:

编号,名称,类别,M1,M2,M3,M4,M5,M6,M7
1,乔治,4,65,35,72,65,56,64,43
2,马丁,4,54,76,23,97,65,43,76

在我的vb.net winform应用程序中,我需要读取文件并以输出格式写入新文件.有关如何执行此操作的任何想法?



My output file should be like this:

No,Name,class,M1,M2,M3,M4,M5,M6,M7
1,George,4,65,35,72,65,56,64,43
2,Martin,4,54,76,23,97,65,43,76

In my vb.net winform application,I need to read the file and write into a new file in output format. Any ideas on how to do this?

推荐答案

将文件逐行加载到数组或列表中.

1)通过分割,字符来拾取前三个字符.
2)然后只需拿起每行中的最后一项
3)将第三项连接到前三项.
4)继续这样做,直到获得前三个字符的新集合.
5)请记住,不要串联前三个字符.

如果遇到任何问题,请尝试一下并在此处发布代码.
Load the file line by line into an array or list.

1)Pick up the first three characters by splitting on the , character.
2)Then simply pick up the last item in each line
3)Concatenate the third item to the first three.
4)Keep doing this till you reach a new set of the first three characters.
5)Remember, don''t concatenate the first three characters.

Give this a try and post the code here if you face any issues.


这篇关于如何在vb.net中将列值写入行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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