I need to extract the data of specific columns from the CSV file and the output should also be a CSV format. I have gone through several solutions to remove data from CSV, but none of them speaks in the CSV format.
Example:
Public Partial Sections Form 1: Form {Public Form 1 () {Initialization (); String filePath = "abc.csv"; String csvContnet = File.ReadAllText (filePath); // E.g. Suppose CSV has 9 columns above 9 and column headers are A, B, C ... I // Now I want to select data from column headers B, C and F with header string. CSICT = this GetRequiredCsvContent (csvContnet); } /// & lt; Summary & gt; /// The following functions require the necessary CSV content from the main CSV file /// & lt; / Summary & gt; /// & lt; Param name = "csvcontnet" & gt; & Lt; / Param & gt; /// & lt; Returns & gt; & Lt; / Returns & gt; Private string GetRequiredCsvContent (string csvContnet) {}}
I'll give you the file. Readline
or file. ReedLeillin
so you can easily do with LINQ
:
var lines = file. Readline ("AD"). Skip (1) // Header Select (line => {var parts = line. Sample (','); return string .join (",", part [1], parts [2], part [5]);} ToList ();
andf
in columns separated by commas Format.
Comments
Post a Comment