<?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>Comments on: Python: Simple File Read and Write</title>
	<atom:link href="http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/</link>
	<description>Software &#62; Technology &#62; Programming for Non-Engineers</description>
	<lastBuildDate>Mon, 02 Jan 2012 20:16:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Lou</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-12057</link>
		<dc:creator>Lou</dc:creator>
		<pubDate>Mon, 25 Jul 2011 20:25:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-12057</guid>
		<description>Ok I have a question on how to write this python script.  I am suppose to write a python code that reads the file y-z TEXT CS-365.txt that prints a two item line for each input line; the first item is to be the input line number; the second item is to be the amount following the word &quot;due&quot; on that line.  

This is the input file
Suzette Jones, begin 01/02/03, end 02/03/04
Michael Smith, begin 12/01/90, end 03/07/99
The Henderson Family, begin 11/3/88, paid   293.77, due 123.45
Doreen Mitchell, begin 09/25/94, due 345.67, paid  133.45

Josh Dominic, begin 06/21/96 due   41.51
Shannon Gaspar, begin 03/21/02, paid 99.99, due  1001.01
Jennifer Allene Pendergast, end 03/31/03</description>
		<content:encoded><![CDATA[<p>Ok I have a question on how to write this python script.  I am suppose to write a python code that reads the file y-z TEXT CS-365.txt that prints a two item line for each input line; the first item is to be the input line number; the second item is to be the amount following the word &#8220;due&#8221; on that line.  </p>
<p>This is the input file<br />
Suzette Jones, begin 01/02/03, end 02/03/04<br />
Michael Smith, begin 12/01/90, end 03/07/99<br />
The Henderson Family, begin 11/3/88, paid   293.77, due 123.45<br />
Doreen Mitchell, begin 09/25/94, due 345.67, paid  133.45</p>
<p>Josh Dominic, begin 06/21/96 due   41.51<br />
Shannon Gaspar, begin 03/21/02, paid 99.99, due  1001.01<br />
Jennifer Allene Pendergast, end 03/31/03</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rev</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-11836</link>
		<dc:creator>rev</dc:creator>
		<pubDate>Fri, 18 Mar 2011 11:35:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-11836</guid>
		<description>how we can get the filename /path in verifymsg during commit?</description>
		<content:encoded><![CDATA[<p>how we can get the filename /path in verifymsg during commit?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rev</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-11831</link>
		<dc:creator>rev</dc:creator>
		<pubDate>Tue, 15 Mar 2011 05:43:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-11831</guid>
		<description>Thanks Daniel

No errors were shown.What can do for this permission problem?

i have tested this scipt in cmd prompt with a sample text file containing id,then it got written to the file.</description>
		<content:encoded><![CDATA[<p>Thanks Daniel</p>
<p>No errors were shown.What can do for this permission problem?</p>
<p>i have tested this scipt in cmd prompt with a sample text file containing id,then it got written to the file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-11820</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Thu, 10 Mar 2011 16:06:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-11820</guid>
		<description>Hey Rev,

At this point you need to start looking at what the errors are when you execute this code. My guess is that there is a permissions problem or something similar. If you can include any errors you are seeing , it will help to identify the problem. Good luck.</description>
		<content:encoded><![CDATA[<p>Hey Rev,</p>
<p>At this point you need to start looking at what the errors are when you execute this code. My guess is that there is a permissions problem or something similar. If you can include any errors you are seeing , it will help to identify the problem. Good luck.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rev</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-11819</link>
		<dc:creator>rev</dc:creator>
		<pubDate>Thu, 10 Mar 2011 06:27:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-11819</guid>
		<description>The code was like this :

id=str(bid)
file = open(“test.txt”, “w”)
file.write(id)

It was not working</description>
		<content:encoded><![CDATA[<p>The code was like this :</p>
<p>id=str(bid)<br />
file = open(“test.txt”, “w”)<br />
file.write(id)</p>
<p>It was not working</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-11812</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Fri, 04 Mar 2011 22:52:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-11812</guid>
		<description>Hi Rev,

Is id an integer or a string? You can try this to convert to a string and see if it works for you:

file = open(&quot;test.txt&quot;, &quot;w&quot;)
file.write(str(id))</description>
		<content:encoded><![CDATA[<p>Hi Rev,</p>
<p>Is id an integer or a string? You can try this to convert to a string and see if it works for you:</p>
<p>file = open(&#8220;test.txt&#8221;, &#8220;w&#8221;)<br />
file.write(str(id))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rev</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-11807</link>
		<dc:creator>rev</dc:creator>
		<pubDate>Thu, 03 Mar 2011 11:07:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-11807</guid>
		<description>I am writing a script to save the id while commiting to server.
file = open(&quot;test.txt&quot;, &quot;w&quot;)
file.write(id)

But while committing ,it is not writing to test.txt</description>
		<content:encoded><![CDATA[<p>I am writing a script to save the id while commiting to server.<br />
file = open(&#8220;test.txt&#8221;, &#8220;w&#8221;)<br />
file.write(id)</p>
<p>But while committing ,it is not writing to test.txt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: heather</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-10829</link>
		<dc:creator>heather</dc:creator>
		<pubDate>Wed, 01 Apr 2009 15:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-10829</guid>
		<description>I agree with your first statements, there is quite a bit of python help out there, but hard to get to the simple stuff.  Am tryng to open a txt file, pull certain parts out, and then write to a new csv....get bits of it, but not the whole process, any help would be great, thanks</description>
		<content:encoded><![CDATA[<p>I agree with your first statements, there is quite a bit of python help out there, but hard to get to the simple stuff.  Am tryng to open a txt file, pull certain parts out, and then write to a new csv&#8230;.get bits of it, but not the whole process, any help would be great, thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: karuppiah</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-10791</link>
		<dc:creator>karuppiah</dc:creator>
		<pubDate>Thu, 12 Feb 2009 14:24:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-10791</guid>
		<description>Hi,&lt;br&gt;I am opening a file in r+ mode. I have a problem in this. If I first write in a file and then read the same file it is working fine. But some junk characters are added to the end of the string. &lt;br&gt;Also one more problem if I read it first say using readline function and then write it, the write operation doesn&#039;t happen. Any idea what might be the problem?</description>
		<content:encoded><![CDATA[<p>Hi,<br />I am opening a file in r+ mode. I have a problem in this. If I first write in a file and then read the same file it is working fine. But some junk characters are added to the end of the string. <br />Also one more problem if I read it first say using readline function and then write it, the write operation doesn&#39;t happen. Any idea what might be the problem?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaun</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-10761</link>
		<dc:creator>shaun</dc:creator>
		<pubDate>Fri, 19 Dec 2008 13:15:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-10761</guid>
		<description>hi, how would you read the whole file in but exclude say the first 4 bytes of it?  &lt;br&gt;thanks&lt;br&gt;sean</description>
		<content:encoded><![CDATA[<p>hi, how would you read the whole file in but exclude say the first 4 bytes of it?  <br />thanks<br />sean</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-10759</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Thu, 18 Dec 2008 17:02:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-10759</guid>
		<description>Well, &lt;br&gt;I would argue that the input is a list already. If you are wanting to return a subset of the GeneCode list, I would do the following.  There are more graceful ways to achieve this, but this method shows you the logic involved.&lt;br&gt;&lt;br&gt;x = [0,1,2,3]&lt;br&gt;GeneCode = [&#039;AAAA&#039;,&#039;AAAC&#039;,&#039;AAAG&#039;,&#039;AAAT&#039;]&lt;br&gt;&lt;br&gt;def Li_to_GC(x):&lt;br&gt;	newList = [GeneCode[i] for i in x]&lt;br&gt;	return newList&lt;br&gt;&lt;br&gt;print Li_to_GC(x)&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;In this case, you can then pass any numeric list to LI_to_GC and get the corresponding Genecodes list back.&lt;br&gt;I would check out this great List comprehension article here, and you can learn more. &lt;a href=&quot;http://effbot.org/zone/python-list.htm&quot; rel=&quot;nofollow&quot;&gt;http://effbot.org/zone/python-list.htm&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Well, <br />I would argue that the input is a list already. If you are wanting to return a subset of the GeneCode list, I would do the following.  There are more graceful ways to achieve this, but this method shows you the logic involved.</p>
<p>x = [0,1,2,3]<br />GeneCode = [&#39;AAAA&#39;,&#39;AAAC&#39;,&#39;AAAG&#39;,&#39;AAAT&#39;]</p>
<p>def Li_to_GC(x):<br />	newList = [GeneCode[i] for i in x]<br />	return newList</p>
<p>print Li_to_GC(x)</p>
<p>In this case, you can then pass any numeric list to LI_to_GC and get the corresponding Genecodes list back.<br />I would check out this great List comprehension article here, and you can learn more. <a href="http://effbot.org/zone/python-list.htm" rel="nofollow">http://effbot.org/zone/python-list.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reza</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-10757</link>
		<dc:creator>Reza</dc:creator>
		<pubDate>Wed, 17 Dec 2008 17:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-10757</guid>
		<description>Thank you Daniel, another problem: &lt;br&gt;x = [0,1,2,3]&lt;br&gt;GeneCode = [&#039;AAAA&#039;,&#039;AAAC&#039;,&#039;AAAG&#039;,&#039;AAAT&#039;]&lt;br&gt;def Li_to_GC(x):&lt;br&gt;    for i in x:&lt;br&gt;            print GeneCode[i],&lt;br&gt;Li_to_GC(x)&lt;br&gt;&lt;br&gt;How can convert the result to the list or string?</description>
		<content:encoded><![CDATA[<p>Thank you Daniel, another problem: <br />x = [0,1,2,3]<br />GeneCode = [&#39;AAAA&#39;,&#39;AAAC&#39;,&#39;AAAG&#39;,&#39;AAAT&#39;]<br />def Li_to_GC(x):<br />    for i in x:<br />            print GeneCode[i],<br />Li_to_GC(x)</p>
<p>How can convert the result to the list or string?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-10747</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Fri, 28 Nov 2008 17:55:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-10747</guid>
		<description>All you need to do is specify the location of the file you want to save to.&lt;br&gt;&lt;br&gt;So when opening the second file, specify the directory then. &lt;br&gt;Example on win32:&lt;br&gt;file = open(&quot;my_dir\newfile.txt&quot;,&quot;w&quot;) &lt;br&gt;Example on *nix :&lt;br&gt;file = open(&quot;my_dir/newfile.txt&quot;,&quot;w&quot;)&lt;br&gt;&lt;br&gt;This will create the new file in the directory &quot;my_dir&quot; assuming the directory exists in the same folder as your python script. You can also specify an absolute file path as well.</description>
		<content:encoded><![CDATA[<p>All you need to do is specify the location of the file you want to save to.</p>
<p>So when opening the second file, specify the directory then. <br />Example on win32:<br />file = open(&#8220;my_dir\newfile.txt&#8221;,&#8221;w&#8221;) <br />Example on *nix :<br />file = open(&#8220;my_dir/newfile.txt&#8221;,&#8221;w&#8221;)</p>
<p>This will create the new file in the directory &#8220;my_dir&#8221; assuming the directory exists in the same folder as your python script. You can also specify an absolute file path as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reza</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/comment-page-1/#comment-10745</link>
		<dc:creator>Reza</dc:creator>
		<pubDate>Fri, 28 Nov 2008 17:04:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8#comment-10745</guid>
		<description>Hi, I have opened my file I have manipulated and I want save this new change in the other directory. At least I know that I should be use &#039; r &#039; for reading and &#039; w &#039; command for writing, but I do not know how I can make connection between readings and manipulate file and writing this manipulation in the other file.&lt;br&gt;Best Regards&lt;br&gt;Reza _ Finland</description>
		<content:encoded><![CDATA[<p>Hi, I have opened my file I have manipulated and I want save this new change in the other directory. At least I know that I should be use &#39; r &#39; for reading and &#39; w &#39; command for writing, but I do not know how I can make connection between readings and manipulate file and writing this manipulation in the other file.<br />Best Regards<br />Reza _ Finland</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Served from: www.techniqal.com @ 2012-02-07 03:21:45 by W3 Total Cache -->
