如何逐行加载CSV blob?
下面的代码示例将整个blob加载到一个字符串中。
最终我想将CSV blob导入Azure SQL。
{
// reference to my blob
var blobRef = "thecsvfiles/Test.csv";
// gets the blob as text
var astring = WindowsAzureStorage.DownloadBlobAsText(blobRef);
Response.Write (astring);
}
答案 0 :(得分:0)
我刚将整个文件加载到一个字符串中,然后拆分为CR和逗号..
string csvData = WindowsAzureStorage.DownloadBlobAsText("thecsvfiles/DiskSpace.csv");
foreach (string row in csvData.Split('\n').Skip(1))
{
if (!string.IsNullOrEmpty(row))
{
dt.Rows.Add();
int i = 1;
foreach (string cell in row.Split(','))
{
dt.Rows[dt.Rows.Count - 1][i] = cell;
i++;
}
}
}