How to read contents of a large csv file and write them to another file with an operator in Python?
<p>I have a csv file of data from a LiDAR sensor that looks like this, but with a bagillion more lines:</p>

<pre><code>scan_0,scan_1,scan_2
timestamp_0,timestamp_1,timestamp_2
7900200,7900225,7900250
logTime_0,logTime_1,logTime_2
27:46.8,27:46.8,27:46.8
distance_0,distance_0,distance_0
132,141,139
136,141,155
139,141,155
138,143,155
138,143,142
139,143,136
138,143,136
</code></pre>

<p>This is data from a planar sensor. So Scan_0 is a list or "radial" coordinates for the specific scan at a time stamp. </p>

<p>My plan is to:</p>

<ol>
<li>Read the CSV file into a list</li>
<li>Create Separate Array's for each scan (columns)</li>
<li><p>Turn each element of the scan array into a xyz format like the example below.</p>

<pre><code>scan_0 -----&gt; scan_0
timestamp_0-&gt; timestamp_0
7900200-----&gt; 7900200
logTime_0---&gt; logTime_0
27:46.8-----&gt; 27:46.8
distance_0--&gt; distance_0
132---------&gt; [132*cos(1),132*sin(1),7900200]
136---------&gt; [136*cos(2),136*sin(2),7900200]
139---------&gt; [139*cos(3),139*sin(3),7900200]
138---------&gt;          .          .
138---------&gt;          .          .
139---------&gt;          .          .
138---------&gt; [138*cos(7),139*sin(7),7900200]
</code></pre></li>
<li><p>Write the array of xyz coordinates to a new csv file with one coordinate per line'</p></li>
<li><p>eventually use a trajectory instead of timestamp for the z coordinate from another csv file.</p></li>
</ol>

<p>I tell you all of this, so you have some context for my motivation. To start this little project, I've decided to simply try and read the csv file into a list and output each of the lines to another csv file... start small right?</p>

<p>here is what I have so far:</p>

<pre><code>import csv 

with open("2016_09_16_14_29_09_953.csv", 'r') as f:
    with open("out.csv", "a") as f1:
        x = csv.reader(f)
        my_list = list(x)
        thedatawriter = csv.writer(f1)
        for row in my_list:
            thedatawriter.write(row)
</code></pre>

<p>This creates an empty csv file. What am I doing wrong here? I feel like an ant climbing mount Everest. Any help, advice, and guidance is greatly appreciated.  </p>

<p>I am not sure why this isn't blowing up on you.  csv.writer objects don't have a write function.  Try thedatawriter.writerow(row) instead.</p>

python