<p>Is there an easy way to convert a string from csv format into a string[] or list?  </p>

<p>I can guarantee that there are no commas in the data.</p>

[{'answer_id': 73390, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': 0, 'selected': False, 'text': "<pre><code>CsvString.split(',');\n</code></pre>\n"}, {'answer_id': 73394, 'author': 'Timothy Carter', 'author_id': 4660, 'author_profile': 'https://Stackoverflow.com/users/4660', 'pm_score': 3, 'selected': True, 'text': "<pre>string[] splitString = origString.Split(',');</pre>\n\n<p><em>(Following comment not added by original answerer)</em>\n<strong>Please keep in mind that this answer addresses the SPECIFIC case where there are guaranteed to be NO commas in the data.</strong></p>\n"}, {'answer_id': 73404, 'author': 'John Sheehan', 'author_id': 1786, 'author_profile': 'https://Stackoverflow.com/users/1786', 'pm_score': 0, 'selected': False, 'text': '<p>Get a string[] of all the lines:  </p>\n\n<pre><code>string[] lines = System.IO.File.ReadAllLines("yourfile.csv");\n</code></pre>\n\n<p>Then loop through and split those lines (this error prone because it doesn\'t check for commas in quote-delimited fields):</p>\n\n<pre><code>foreach (string line in lines)\n{\n    string[] items = line.Split({\',\'}};\n}\n</code></pre>\n'}, {'answer_id': 73414, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<pre><code>string test = "one,two,three";\nstring[] okNow = test.Split(\',\');\n</code></pre>\n'}, {'answer_id': 73416, 'author': 'Bob King', 'author_id': 6897, 'author_profile': 'https://Stackoverflow.com/users/6897', 'pm_score': 0, 'selected': False, 'text': '<pre><code>string s = "1,2,3,4,5";\n\nstring myStrings[] = s.Split({\',\'}};\n</code></pre>\n\n<p>Note that Split() takes an <em>array</em> of characters to split on.</p>\n'}, {'answer_id': 73419, 'author': 'Paul van Brenk', 'author_id': 1837197, 'author_profile': 'https://Stackoverflow.com/users/1837197', 'pm_score': 0, 'selected': False, 'text': "<pre><code>separationChar[] = {';'}; // or '\\t' ',' etc.\nvar strArray = strCSV.Split(separationChar);\n</code></pre>\n"}, {'answer_id': 73426, 'author': 'Ryan Steckler', 'author_id': 12673, 'author_profile': 'https://Stackoverflow.com/users/12673', 'pm_score': 0, 'selected': False, 'text': '<pre><code>string[] splitStrings = myCsv.Split(",".ToCharArray());\n</code></pre>\n'}, {'answer_id': 73460, 'author': 'John Sheehan', 'author_id': 1786, 'author_profile': 'https://Stackoverflow.com/users/1786', 'pm_score': 3, 'selected': False, 'text': '<p>If you want robust CSV handling, check out <a href="http://www.filehelpers.com/" rel="nofollow noreferrer">FileHelpers</a></p>\n'}, {'answer_id': 73466, 'author': 'Eric Z Beard', 'author_id': 1219, 'author_profile': 'https://Stackoverflow.com/users/1219', 'pm_score': 1, 'selected': False, 'text': "<p>There isn't a simple way to do this well, if you want to account for quoted elements with embedded commas, especially if they are mixed with non-quoted fields.</p>\n\n<p>You will also probably want to convert the lines to a dictionary, keyed by the column name.</p>\n\n<p>My code to do this is several hundred lines long.</p>\n\n<p>I think there are some examples on the web, open source projects, etc.</p>\n"}, {'answer_id': 73526, 'author': 'Panos', 'author_id': 8049, 'author_profile': 'https://Stackoverflow.com/users/8049', 'pm_score': 2, 'selected': False, 'text': '<p>Try:</p>\n\n<pre><code>Regex rex = new Regex(",(?=([^\\"]*\\"[^\\"]*\\")*(?![^\\"]*\\"))");\nstring[] values = rex.Split( csvLine );\n</code></pre>\n\n<p>Source: <a href="http://weblogs.asp.net/prieck/archive/2004/01/16/59457.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/prieck/archive/2004/01/16/59457.aspx</a></p>\n'}, {'answer_id': 73557, 'author': 'Sam', 'author_id': 9406, 'author_profile': 'https://Stackoverflow.com/users/9406', 'pm_score': 0, 'selected': False, 'text': '<p>Some CSV files have double quotes around the values along with a comma. Therefore sometimes you can split on this string literal: "," </p>\n'}, {'answer_id': 73609, 'author': 'claco', 'author_id': 91911, 'author_profile': 'https://Stackoverflow.com/users/91911', 'pm_score': 0, 'selected': False, 'text': '<p><del>A Csv file with Quoted fields, is not a Csv file. Far more things (Excel) output without quotes rather than with quotes when you select "Csv" in a save as.</del></p>\n\n<p>If you want one you can use, free, or commit to, here\'s mine that also does IDataReader/Record. It also uses DataTable to define/convert/enforce columns and DbNull.</p>\n\n<p><a href="http://github.com/claco/csvdatareader/" rel="nofollow noreferrer">http://github.com/claco/csvdatareader/</a></p>\n\n<p>It doesn\'t do quotes.. yet. I just tossed it together a few days ago to scratch an itch.</p>\n\n<p>Forgotten Semicolon: Nice link. Thanks.\ncfeduke: Thanks for the tip to Microsoft.VisualBasic.FileIO.TextFieldParser. Going into CsvDataReader tonight.</p>\n'}, {'answer_id': 73639, 'author': 'Philip Rieck', 'author_id': 12643, 'author_profile': 'https://Stackoverflow.com/users/12643', 'pm_score': 4, 'selected': False, 'text': '<p>String.Split is just not going to cut it, but a Regex.Split may - Try this one:</p>\n\n<pre><code>using System.Text.RegularExpressions;\n\nstring[] line;\nline = Regex.Split( input, ",(?=(?:[^\\"]*\\"[^\\"]*\\")*(?![^\\"]*\\"))");\n</code></pre>\n\n<p>Where \'input\' is the csv line.  This will handle quoted delimiters, and should give you back an array of strings representing each field in the line.</p>\n'}, {'answer_id': 73980, 'author': 'cfeduke', 'author_id': 5645, 'author_profile': 'https://Stackoverflow.com/users/5645', 'pm_score': 2, 'selected': False, 'text': "<p>You can take a look at using the Microsoft.VisualBasic assembly with the</p>\n\n<pre><code>Microsoft.VisualBasic.FileIO.TextFieldParser\n</code></pre>\n\n<p>It handles CSV (or any delimiter) with quotes.  I've found it quite handy recently.</p>\n"}, {'answer_id': 74093, 'author': 'Steve Cooper', 'author_id': 6722, 'author_profile': 'https://Stackoverflow.com/users/6722', 'pm_score': 1, 'selected': False, 'text': '<p>Try this; </p>\n\n<pre><code>static IEnumerable&lt;string&gt; CsvParse(string input)\n{\n    // null strings return a one-element enumeration containing null.\n    if (input == null)\n    {\n        yield return null;\n        yield break;\n    }\n\n    // we will \'eat\' bits of the string until it\'s gone.\n    String remaining = input;\n    while (remaining.Length &gt; 0)\n    {\n\n        if (remaining.StartsWith("\\"")) // deal with quotes\n        {\n            remaining = remaining.Substring(1); // pass over the initial quote.\n\n            // find the end quote.\n            int endQuotePosition = remaining.IndexOf("\\"");\n            switch (endQuotePosition)\n            {\n                case -1:\n                    // unclosed quote.\n                    throw new ArgumentOutOfRangeException("Unclosed quote");\n                case 0:\n                    // the empty quote\n                    yield return "";\n                    remaining = remaining.Substring(2);\n                    break;\n                default:\n                    string quote = remaining.Substring(0, endQuotePosition).Trim();\n                    remaining = remaining.Substring(endQuotePosition + 1);\n                    yield return quote;\n                    break;\n            }\n        }\n        else // deal with commas\n        {\n            int nextComma = remaining.IndexOf(",");\n            switch (nextComma)\n            {\n                case -1:\n                    // no more commas -- read to end\n                    yield return remaining.Trim();\n                    yield break;\n\n                case 0:\n                    // the empty cell\n                    yield return "";\n                    remaining = remaining.Substring(1);\n                    break;\n\n                default:\n                    // get everything until next comma\n                    string cell = remaining.Substring(0, nextComma).Trim();\n                    remaining = remaining.Substring(nextComma + 1);\n                    yield return cell;\n                    break;\n            }\n        }\n    }\n\n}\n</code></pre>\n'}, {'answer_id': 80025, 'author': 'claco', 'author_id': 91911, 'author_profile': 'https://Stackoverflow.com/users/91911', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://github.com/claco/csvdatareader/" rel="nofollow noreferrer">http://github.com/claco/csvdatareader/</a> updated using TextFieldParser suggested by cfeduke.</p>\n\n<p>Just a few props away from exposing separators/trimspaces/type ig you just need code to steal.</p>\n'}, {'answer_id': 84639, 'author': 'JohnOpincar', 'author_id': 16245, 'author_profile': 'https://Stackoverflow.com/users/16245', 'pm_score': 0, 'selected': False, 'text': '<p>I was already splitting on tabs so this did the trick for me:</p>\n\n<pre><code>public static string CsvToTabDelimited(string line) {\n    var ret = new StringBuilder(line.Length);\n    bool inQuotes = false;\n    for (int idx = 0; idx &lt; line.Length; idx++) {\n        if (line[idx] == \'"\') {\n            inQuotes = !inQuotes;\n        } else {\n            if (line[idx] == \',\') {\n                ret.Append(inQuotes ? \',\' : \'\\t\');\n            } else {\n                ret.Append(line[idx]);\n            }\n        }\n    }\n    return ret.ToString();\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/73385', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12653/']