Parsing semi colon delimeter file
<p>I have a CSV file but the delimiter is a semi colon <code>;</code> and each column is enclosed with double quotes. There are also occurrences of <code>;</code> in some values such as <code>&amp; amp;</code></p>

<p>I am using <em>TextFieldParser</em> to parse the file. This is the sample data:</p>

<blockquote>
  <p><code>"A001";"RT:This is a tweet"; "http://www.whatever.com/test/module &amp; amp;one"</code></p>
</blockquote>

<p>For the above example , I am getting more columns/fields than what I should get.</p>

<blockquote>
  <p><code>Field[0] = "A001"</code><br>
  <code>Field[1] = "RT:This is a tweet"</code><br>
  <code>Field[2] = "http://www.whatever.com/test/module&amp;amp"</code><br>
  <code>Field[3] = "one"</code></p>
</blockquote>

<p>This is my code. What changes need to be done to handle such scenario?</p>

<pre><code> using (var parser  =  new TextFieldParser(fileName))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(";");
                parser.TrimWhiteSpace = true;
                parser.HasFieldsEnclosedInQuotes = false;

                int rowIndex = 0;
                PropertyInfo[] properties = typeof(TwitterData).GetProperties();
                while (parser.PeekChars(1) != null)
                {
                    var cleanFieldRowCells = parser.ReadFields().Select(
                        f =&gt; f.Trim(new[] { ' ', '"' }));

                    var twitter = new TwitterData();
                    int index = 0;
                    foreach (string c in cleanFieldRowCells)
                    {
                            string str = c;

                            if (properties[index].PropertyType == typeof(DateTime))
                            {
                                string twitterDateTemplate = "ddd MMM dd HH:mm:ss +ffff yyyy";
                                DateTime createdAt = DateTime.ParseExact(str, twitterDateTemplate, new System.Globalization.CultureInfo("en-AU"));
                                properties[index].SetValue(twitter, createdAt);
                            }
                            else
                            {
                                properties[index].SetValue(twitter, str);
                            }

                        index++;
                    }
                }
</code></pre>

<p>-Alan-</p>