Deleting blank rows and rows with text in them at the same time
<p>New to programming here. After going through google and the forums (aswell as much trial and error), I couldn't find a neat solution to my problem.</p>

<p>I'd like to delete a few initial rows (first 10 rows) in my spreadsheet/CSV file and while I did find the solution to that using:</p>

<pre><code>    all(next(read) for i in range(10))
</code></pre>

<p>It does not appear to be able to delete the blank rows in the CSV file that I have. The first 10 rows I'd like to delete include those blank rows. I think the above line only deletes the rows if there are strings in them.</p>

<p>My full code is this so far [EDIT1]: Maybe this could work?</p>

<pre><code>    import csv
    with open('filename.csv') as csvfile:
       non_blank_row=[]
       filecsv = csv.reader(csvfile, delimiter=",")
       for row in filecsv:
              non_blank_row.append(row)

       better_blank_row = non_blank_row[[i for i in range(len(non_blank_row)) if non_blank_row!=[]
</code></pre>

<p>[EDIT2]: When I tried to print(better_blank_row), I did:</p>

<pre><code>    for i in better_blank_row:
        print(better_blank_row)
</code></pre>

<p>However, I'm not sure why output doesn't come out.. like the shell just freezes.
Any help would be much appreciated!</p>

<p>you can use as fallowing for writing new csv file after deleting particuler row's </p>

<pre><code>import csv
#read csv file
csvfile =  open('/home/17082016_ExpiryReport.csv', 'rb')
filecsv = csv.reader(csvfile, delimiter=",")

#following line increment pointer for blank line also up to range 10 lines  
[next(filecsv) for i in range(10)]

#write csv file
with open('/home/17082016_ExpiryReport_output.csv', 'wb') as csvfile:
    csvwriter = csv.writer(csvfile, delimiter=',')
    [csvwriter.writerow(i) for i in filecsv ]
</code></pre>

python csv rows