如何导出多个csv文件中的数据? [英] How to export data in multiple csv files?

查看:128
本文介绍了如何导出多个csv文件中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿朋友,



i有导出方法运行gr8ly现在我必须将数据导出到多个单独的文件中,这些文件基于以下查询,



DataExport(字符串查询,字符串文件名)////这是初始方法////



DataExport( SELECT * FROM SaiRamH WHERE [WARD NAME] ='GENERAL WARD(FEMALE)'和[REGNO / ID] ='SH1401 / 00457';,GenF0457.csv);



但是我的问题出现在这里,我想根据病房名称nad regno / id导出数据,但是有大量的患者数据和regno / id不是串行值将它放在循环上,它不是可以为每位患者开除qury,并为每位患者指定regno / id。我真的不知道怎么做。



当我运行上面的方法我想创建一个名称由病房名称的前三个字母和后四个字母组成的csv文件regno / id的数字。应该从数据库中恢复和regno / id和wardname作为表中的数据保存。自动从表中捕获两者而不指定查询。



例如:



这里是数据库中的记录

wardname, regno / id

generalfemale,SH400 / 0023

icu,SH408 / 0804



嘿朋友我发现答案我自己通过以下方法,



public void exportAll()//函数声明要导出的方法//

{

int i = 0;

for(int icount = 0; icount< = 15; icount ++)

{



Object o = saiRamDataSet11.Tables [" SaiRamH"] .Rows [i] [" WARD NAME"];

Object ob = saiRamDataSet11.Tables [" SaiRamH" ] .Rows [i] [" REGNO / ID"];



DataExport(" select * from SaiRamH where [WARD NAME] ='" + o +"'" +

"和[REGNO / ID] ='" + ob +"'"," count" + icount +" .csv&quo t;);

i ++;

}

Hey Friends,

i have export method which running gr8ly now i have to export data into multiple separate files which based on the following query,

DataExport(string query,string filename) ////this is intial method////

DataExport("SELECT * FROM SaiRamH WHERE [WARD NAME]= 'GENERAL WARD (FEMALE)' AND [REGNO/ID]= 'SH1401/00457';", "GenF0457.csv");

But my problem arises here that i want to export data based on ward name nad regno/id , but there is huge data of patients and regno/id is not serial value to put it on loop, and it is not possible to fire qury for each patient and specify regno/id for each patient. i really dont know how to do it.

when i run above method i want to create a csv file with name consist of first three letters of ward name and last four digits of regno/id. and regno/id and wardname should be retrived from database as datasaved in table serialy. automatically catch both from table without specifying into query.

for example:

here is record in database
wardname,regno/id
generalfemale,SH400/0023
icu,SH408/0804

hey friends i found answer myself by the following method,

public void exportAll()//Function declares methods to export//
{
int i = 0;
for (int icount = 0; icount <= 15; icount++)
{

Object o = saiRamDataSet11.Tables["SaiRamH"].Rows[i]["WARD NAME"];
Object ob = saiRamDataSet11.Tables["SaiRamH"].Rows[i]["REGNO/ID"];

DataExport("select * from SaiRamH where [WARD NAME]='" + o + "'" +
"and [REGNO/ID] ='" + ob + "'", "count"+icount+".csv");
i++;
}

推荐答案

参考此链接



http://caioproiete.net/ en / split-text-file-into-several -files-using-csharp / [ ^ ]


这篇关于如何导出多个csv文件中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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