<?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/"
	
	>
<channel>
	<title>
	「一个奇怪的 Python CSV 处理问题」的评论	</title>
	<atom:link href="https://www.lab-z.com/pycsv/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lab-z.com/pycsv/</link>
	<description></description>
	<lastBuildDate>Sat, 04 Apr 2020 00:45:08 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>
		评论者：ziv2013		</title>
		<link>https://www.lab-z.com/pycsv/#comment-91238</link>

		<dc:creator><![CDATA[ziv2013]]></dc:creator>
		<pubDate>Sat, 04 Apr 2020 00:45:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=7223#comment-91238</guid>

					<description><![CDATA[回复给 &lt;a href=&quot;https://www.lab-z.com/pycsv/#comment-91228&quot;&gt;krishna&lt;/a&gt;。

专业啊]]></description>
			<content:encoded><![CDATA[<p>回复给 <a href="https://www.lab-z.com/pycsv/#comment-91228">krishna</a>。</p>
<p>专业啊</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：krishna		</title>
		<link>https://www.lab-z.com/pycsv/#comment-91228</link>

		<dc:creator><![CDATA[krishna]]></dc:creator>
		<pubDate>Fri, 03 Apr 2020 08:00:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=7223#comment-91228</guid>

					<description><![CDATA[//分享另一种解法，使用flex(或者antlr)，以下是mylex.flex的内容：
%OPTION noyywrap
%{
#define ECHO
%}
%%
[0-9]{2}&quot;:&quot;[0-9]{2}&quot;:&quot;[0-9]{2}&quot;.&quot;[0-9]+&quot; &quot;([A]&#124;[P])[M] {printf(&quot;time is: %s\n&quot;,yytext);}
%%
int main()
{
  while(yylex())
  {
	//nothing;
  }
  return 0;
}

//以下是测试输出：
E:\temp\test&#062;flex --wincompat mylex.flex

E:\temp\test&#062;cl lex.yy.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26730 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

lex.yy.c
Microsoft (R) Incremental Linker Version 14.15.26730.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:lex.yy.exe
lex.yy.obj

E:\temp\test&#062;type DataX.CSV &#124; lex.yy.exe
time is: 10:21:22.8436230 PM
time is: 10:21:22.8436625 PM
time is: 10:21:22.8436974 PM
time is: 10:21:22.8440542 PM
time is: 10:21:22.8440997 PM
time is: 10:21:22.8441291 PM
time is: 10:21:22.8442544 PM

//flex可以在这里下载：https://sourceforge.net/projects/winflexbison/]]></description>
			<content:encoded><![CDATA[<p>//分享另一种解法，使用flex(或者antlr)，以下是mylex.flex的内容：<br />
%OPTION noyywrap<br />
%{<br />
#define ECHO<br />
%}<br />
%%<br />
[0-9]{2}&#8221;:&#8221;[0-9]{2}&#8221;:&#8221;[0-9]{2}&#8221;.&#8221;[0-9]+&#8221; &#8220;([A]|[P])[M] {printf(&#8220;time is: %s\n&#8221;,yytext);}<br />
%%<br />
int main()<br />
{<br />
  while(yylex())<br />
  {<br />
	//nothing;<br />
  }<br />
  return 0;<br />
}</p>
<p>//以下是测试输出：<br />
E:\temp\test&gt;flex &#8211;wincompat mylex.flex</p>
<p>E:\temp\test&gt;cl lex.yy.c<br />
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26730 for x64<br />
Copyright (C) Microsoft Corporation.  All rights reserved.</p>
<p>lex.yy.c<br />
Microsoft (R) Incremental Linker Version 14.15.26730.0<br />
Copyright (C) Microsoft Corporation.  All rights reserved.</p>
<p>/out:lex.yy.exe<br />
lex.yy.obj</p>
<p>E:\temp\test&gt;type DataX.CSV | lex.yy.exe<br />
time is: 10:21:22.8436230 PM<br />
time is: 10:21:22.8436625 PM<br />
time is: 10:21:22.8436974 PM<br />
time is: 10:21:22.8440542 PM<br />
time is: 10:21:22.8440997 PM<br />
time is: 10:21:22.8441291 PM<br />
time is: 10:21:22.8442544 PM</p>
<p>//flex可以在这里下载：https://sourceforge.net/projects/winflexbison/</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：Simon		</title>
		<link>https://www.lab-z.com/pycsv/#comment-91065</link>

		<dc:creator><![CDATA[Simon]]></dc:creator>
		<pubDate>Wed, 25 Mar 2020 14:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=7223#comment-91065</guid>

					<description><![CDATA[import csv, os

try:
    import chardet
except ModuleNotFoundError:
    raise Error(&quot;Please install chardet by \&quot;pip install chardet\&quot; first.&quot;)

def checkEncoding(file):
    bytes = min(32, os.path.getsize(file))
    raw = open(file, &#039;rb&#039;).read(bytes)
    result = chardet.detect(raw)
    encoding = result[&#039;encoding&#039;]
    return encoding

with open(&#039;Datax.CSV&#039;, encoding=checkEncoding(&#039;Datax.CSV&#039;)) as csvfile:
	reader = csv.DictReader(csvfile)
	for row in reader:
		print(row[&#039;Time of Day&#039;])]]></description>
			<content:encoded><![CDATA[<p>import csv, os</p>
<p>try:<br />
    import chardet<br />
except ModuleNotFoundError:<br />
    raise Error(&#8220;Please install chardet by \&#8221;pip install chardet\&#8221; first.&#8221;)</p>
<p>def checkEncoding(file):<br />
    bytes = min(32, os.path.getsize(file))<br />
    raw = open(file, &#8216;rb&#8217;).read(bytes)<br />
    result = chardet.detect(raw)<br />
    encoding = result[&#8216;encoding&#8217;]<br />
    return encoding</p>
<p>with open(&#8216;Datax.CSV&#8217;, encoding=checkEncoding(&#8216;Datax.CSV&#8217;)) as csvfile:<br />
	reader = csv.DictReader(csvfile)<br />
	for row in reader:<br />
		print(row[&#8216;Time of Day&#8217;])</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
