简体   繁体   中英

How to extract text from specific columns from a csv file in c#?

I have been working on extracting text from a csv file and store the data in a string. But now, I would like to extract text from some of the specific columns and store the data in a string.I would like the wordDocContents variable to contain the specific columns and the data in those specific columns which is bank_account , bank_name , customer_name . Currently, my wordDocContents has the entire data from my csv file. Is there a way to filter out the specific columns and the data in those columns and store it in the variable wordDocContents . Thanks

Here is what I tried so far -

public void button1Clicked(object sender, EventArgs args)
{
    button1.Text = "You clicked me";

    var textExtractor = new TextExtractor();

    var wordDocContents = textExtractor.Extract("t.csv");
    Console.WriteLine(wordDocContents);
    Console.ReadLine();
}

I believe you are looking for class to parse structured files.

Check out https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser.aspx for details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM