<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" 	>
<channel>
	<title>Comments on: Parsing textfiles with LINQ (or LINQ-to-TextReader)</title>
	<atom:link href="http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/</link>
	<description>Arjan: Technical Learnings of Programmings for Make Benefit Glorious Framework of .NET</description>
	<lastBuildDate>Fri, 19 Feb 2010 14:16:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: The trouble with delimited &#171; Arjans blog</title>
		<link>http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/comment-page-1/#comment-308</link>
		<dc:creator>The trouble with delimited &#171; Arjans blog</dc:creator>
		<pubDate>Fri, 31 Jul 2009 09:34:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.einbu.no/?p=118#comment-308</guid>
		<description>[...] this previous article articles about parsing files, I took a very simplistic approach to reading a delimited file. I used string.Split, which [...]</description>
		<content:encoded><![CDATA[<p>[...] this previous article articles about parsing files, I took a very simplistic approach to reading a delimited file. I used string.Split, which [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jim b</title>
		<link>http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/comment-page-1/#comment-34</link>
		<dc:creator>jim b</dc:creator>
		<pubDate>Thu, 14 May 2009 14:29:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.einbu.no/?p=118#comment-34</guid>
		<description>DUH.. it goes here:

using (var reader = new StreamReader(@&quot;c:\rejects.txt&quot;))
			{
				var query = from line in reader.AsEnumerable() //skip header row
							//let columns = line.Split(&#039;,&#039;)
							let columns =  Regex.Split(line, expr) 
							select new
							{
								Firstname = columns[0],
								Lastname = columns[1],
								Age = columns[2]
							};</description>
		<content:encoded><![CDATA[<p>DUH.. it goes here:</p>
<p>using (var reader = new StreamReader(@&#8221;c:\rejects.txt&#8221;))<br />
			{<br />
				var query = from line in reader.AsEnumerable() //skip header row<br />
							//let columns = line.Split(&#8216;,&#8217;)<br />
							let columns =  Regex.Split(line, expr)<br />
							select new<br />
							{<br />
								Firstname = columns[0],<br />
								Lastname = columns[1],<br />
								Age = columns[2]<br />
							};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jim b</title>
		<link>http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/comment-page-1/#comment-33</link>
		<dc:creator>jim b</dc:creator>
		<pubDate>Thu, 14 May 2009 14:22:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.einbu.no/?p=118#comment-33</guid>
		<description>hi, thanks for that... 
sorry for being rude, was a bit frustrated.
Expanding on this idea..
say my splits is a bit more complex:

&quot;Salutation&quot;,&quot;First, Name&quot;,&quot;Middle,, Name&quot;,&quot;Last,,, Name&quot;

the file is delimited by commas and fields have quotes if there is data. if there happens to be a comma in the quotes we DON&quot;T want to split. 

so i was thinking regex like this:


	public static IEnumerable AsEnumerable(this TextReader reader)
		{
			string expr = &quot;(?&lt;=\&quot;),(?=\&quot;)&quot;; 
				string line;
				while ((line = reader.ReadLine()) != null)
				{
					yield return Regex.Split(line, expr);
				}
			}

dosn&#039;t work tho.. can&#039;t implicitly convert string[] to string.</description>
		<content:encoded><![CDATA[<p>hi, thanks for that&#8230;<br />
sorry for being rude, was a bit frustrated.<br />
Expanding on this idea..<br />
say my splits is a bit more complex:</p>
<p>&#8220;Salutation&#8221;,&#8221;First, Name&#8221;,&#8221;Middle,, Name&#8221;,&#8221;Last,,, Name&#8221;</p>
<p>the file is delimited by commas and fields have quotes if there is data. if there happens to be a comma in the quotes we DON&#8221;T want to split. </p>
<p>so i was thinking regex like this:</p>
<p>	public static IEnumerable AsEnumerable(this TextReader reader)<br />
		{<br />
			string expr = &#8220;(?&lt;=\&#8221;),(?=\&#8221;)&#8221;;<br />
				string line;<br />
				while ((line = reader.ReadLine()) != null)<br />
				{<br />
					yield return Regex.Split(line, expr);<br />
				}<br />
			}</p>
<p>dosn&#8217;t work tho.. can&#8217;t implicitly convert string[] to string.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arjan Einbu</title>
		<link>http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/comment-page-1/#comment-29</link>
		<dc:creator>Arjan Einbu</dc:creator>
		<pubDate>Mon, 11 May 2009 20:46:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.einbu.no/?p=118#comment-29</guid>
		<description>Thanks for the response, and sorry for my typo. While working on my my post, I changed the name of the GetLines method to AsEnumerable. The GetLines you found must have slipped through...
Anyway, &lt;strong&gt;its fixed now&lt;/strong&gt;, and your second questions should be easy to answer now too: line is a string, and strings have a Split method on them...</description>
		<content:encoded><![CDATA[<p>Thanks for the response, and sorry for my typo. While working on my my post, I changed the name of the GetLines method to AsEnumerable. The GetLines you found must have slipped through&#8230;<br />
Anyway, <strong>its fixed now</strong>, and your second questions should be easy to answer now too: line is a string, and strings have a Split method on them&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jim b</title>
		<link>http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/comment-page-1/#comment-28</link>
		<dc:creator>jim b</dc:creator>
		<pubDate>Mon, 11 May 2009 20:14:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.einbu.no/?p=118#comment-28</guid>
		<description>this looks great. too bad it dosn&#039;t work. this is one of those annoying posts that leaves out just enough info so that if you couldn&#039;t have done it in the first place anyway you won&#039;t be able to use it. 
where does the reader.GetLines() method come from.
how does the array &quot;line&quot; get the Split method. let&#039;s just keep it a secret.</description>
		<content:encoded><![CDATA[<p>this looks great. too bad it dosn&#8217;t work. this is one of those annoying posts that leaves out just enough info so that if you couldn&#8217;t have done it in the first place anyway you won&#8217;t be able to use it.<br />
where does the reader.GetLines() method come from.<br />
how does the array &#8220;line&#8221; get the Split method. let&#8217;s just keep it a secret.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: More parsing textfiles with LINQ &#171; Arjans blog</title>
		<link>http://blog.einbu.no/2009/03/parsing-textfiles-with-linq/comment-page-1/#comment-9</link>
		<dc:creator>More parsing textfiles with LINQ &#171; Arjans blog</dc:creator>
		<pubDate>Thu, 02 Apr 2009 17:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.einbu.no/?p=118#comment-9</guid>
		<description>[...] In a previous article, I described how to use LINQ when parsing a textfile. [...]</description>
		<content:encoded><![CDATA[<p>[...] In a previous article, I described how to use LINQ when parsing a textfile. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
