user7135817
user7135817

Reputation:

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();
}

Upvotes: 0

Views: 198

Answers (1)

Ryan Johnson
Ryan Johnson

Reputation: 44

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.

Upvotes: 2

Related Questions