我需要從CSV文件中提取特定列的數據,輸出也應該是CSV格式。 我已經經歷了大約從CSV中提取數據的多種解決方案走了,但他們沒有關於CSV格式提取它本身以csv格式自行提取csv文件中的特定列
舉例談到:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string filePath = "abc.csv";
string csvContnet = File.ReadAllText(filePath);
// E.g. Suppose above csv has 9 columns
// And column headers are from A,B,C...I
// Now I want to select data from columheaders B,C and F along with header
string requiredCsvContent = this.GetRequiredCsvContent(csvContnet);
}
/// <summary>
/// Following function returns required CSV content from main csv File
/// </summary>
/// <param name="csvContnet"></param>
/// <returns></returns>
private string GetRequiredCsvContent(string csvContnet)
{
}}
你能發表一個例子嗎? – ken2k
請通過編輯 – Nilesh
你能否澄清一下這個例子?你有9個標題(A - > I),但只有7列? – ken2k