如何划分大型Excel Csv文件并存储在数据库表中? [英] How Can I Divide Large Excel Csv File And Stored In A Database Table?

查看:83
本文介绍了如何划分大型Excel Csv文件并存储在数据库表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的excel csv文件(大约2000列)我想将这些数据存储到我的基于本地服务的数据表中。但是本地dB只支持1024列。因此我必须将csv分成几个部分并存储到数据库中。如何划分并存储到多个表中?我要在db中一起显示数据。如何通过c#代码完成所有这些事情?请帮助我。

I have large excel csv file(about 2000 columns)I want to store these data into my Local service based data table. But local dB support only 1024 columns.so I have to divide that csv into several parts and stored in to the database. How can I divide and stored into multiple table? and I've to show the data together in db. How can I do all these things through c# codes?? please help me.

推荐答案

按照以下步骤





1)在SQL数据库中创建两个表。

2)将它们命名为Tbl_Part_1和Tbl_Part_2

Tbl_Part_1将包含1023列CSV和一个额外列以存储RowKey

Tbl_Part_2将包含977列CSV和一个额外列以存储RowKey

3)读取包含所有2000列的CSV文件

4)在C#中生成一个Unicode密钥并将其存储在某个变量中

5)获取前1023列并将其存储在Tbl_Part_1中unicode key

6)在第二张表中存储剩下的977列并使用相同的unicode键



我希望这会有所帮助,否则让我知道你是否需要特定代码



-

RDBurmon

希望这有帮助,如果是,那么请接受答案并投票


Ther e是另一种称为宽桌子的解决方案。



但它带有几个陷阱。

首先是好新的,你可以表中有多达30000列。

但坏消息是每行限制为8019个字节,这意味着您需要在许多列中使用空值才能够挤压在所有数据中。

有关 msdn的更多信息 [ ^ ]。



如果这对您不起作用,则需要使用解决方案一。
There is another solution called "Wide Tables".

But it come with a couple of gotchas.
First the good new, you can have up to 30000 columns in a table.
But the bad news is that you're limited to 8019 bytes per row, which means that you need to nulls in many of the columns to be able to squeeze in all the data.
More info on msdn[^].

If this doesn't work for you, you need to use solution one.


这篇关于如何划分大型Excel Csv文件并存储在数据库表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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