Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your question is a little vague, but I'll try and answer it as best I can.</p> <p>A CSV file is (by definition) a file containing comma seperated values - the key here is that a comma is used as the delimiter. Personally, I find that using a different delimiter is prone to less nasties when parsing.</p> <p>I've created the following test CSV file:</p> <pre><code>Column1,Column2,Column3,Column4 Row1Value1,Row1Value2,Row1Value3,Row1Value4 Row2Value1,Row2Value2,Row2Value3,Row2Value4 Row3Value1,Row3Value2,Row3Value3,Row3Value4 Row4Value1,Row4Value2,Row4Value3,Row4Value4 Row5Value1,Row5Value2,Row5Value3,Row5Value4 </code></pre> <p>Here's some code to read that file into some simple structures that you can then manipulate. You might want to extend this code by creating classes for the columns and rows (and values as well).</p> <pre><code> string sFileContents = ""; using (StreamReader oStreamReader = new StreamReader(File.OpenRead("Test.csv"))) { sFileContents = oStreamReader.ReadToEnd(); } List&lt;string[]&gt; oCsvList = new List&lt;string[]&gt;(); string[] sFileLines = sFileContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string sFileLine in sFileLines) { oCsvList.Add(sFileLine.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); } int iColumnNumber = 0; int iRowNumber = 0; Console.WriteLine("Column{0}, Row{1} = \"{2}\"", iColumnNumber, iRowNumber, oCsvList[iColumnNumber][iRowNumber]); iColumnNumber = 4; iRowNumber = 2; Console.WriteLine("Column{0}, Row{1} = \"{2}\"", iColumnNumber, iRowNumber, oCsvList[iColumnNumber][iRowNumber]); </code></pre> <p>Keep in mind that values are accessed by the column number, and then the row number.</p> <p>I hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload