我已加载CSV文件
以下是CSV文件中可用内容的示例
Name,Address,Address1,LandMark,User_location,City,State,Phone1,Phone2,Email,Category
Sriram Electricals and Plumbing Contractors,No 12, Vinayakar Koil Street Easa,"Back Side Of Therasa School,",Pallavaram,Chennai,Tamil Nadu,(044) 66590405,,sriram@gmail.com,Electrican
我已尝试将文件转换为列表
public ActionResult UserCsv(HttpPostedFileBase uploadfile)
{
using (var sr = new StreamReader(uploadfile.InputStream, Encoding.UTF8))
{
var reader = new CsvReader(sr);
//CSVReader will now read the whole file into an enumerable
IEnumerable<UserCSVModel> records = reader.GetRecords<UserCSVModel>();
}
}
无法获得正确的输出。
答案 0 :(得分:0)
试试这篇文章:
http://www.codeproject.com/Articles/415732/Reading-and-Writing-CSV-Files-in-Csharp
或者堆栈溢出的Q:
希望它有所帮助。答案 1 :(得分:0)
看看http://www.filehelpers.net/。它是一个很棒的库,用于处理CSV文件,并为您提供可以使用的Enumerable