CSV file creation error in python
<p>I am getting some error while writing contents to csv file in python</p>

<pre><code>import sys  

reload(sys)  
sys.setdefaultencoding('utf8')
import csv
a = [['1/1/2013', '1/7/2013'], ['1/8/2013', '1/14/2013'], ['1/15/2013', '1/21/2013'], ['1/22/2013', '1/28/2013'], ['1/29/2013', '1/31/2013']]


f3 = open('test_'+str(a[0][0])+'_.csv', 'at')
writer = csv.writer(f3,delimiter = ',', lineterminator='\n',quoting=csv.QUOTE_ALL)
writer.writerow(a)
</code></pre>

<p>Error</p>

<pre><code>Traceback (most recent call last):
  File "test.py", line 10, in &lt;module&gt;
    f3 = open('test_'+str(a[0][0])+'_.csv', 'at')
IOError: [Errno 2] No such file or directory: 'test_1/1/2013_.csv'
</code></pre>

<p>How to fix it and what is the error?</p>

<p>You have error message - just read it.
The file test_1/1/2013_.csv doesn't exist.</p>

<p>In the file name that you create - you use a[0][0] and in this case it result in 1/1/2013.
Probably this two signs '/' makes that you are looking for this file in bad directory.
Check where are this file (current directory - or in .test_1/1 directory.</p>

python csv