0
I had made the following code in codevy.io and Python installed in codenvy is 3.5.1. I took this code and put to run in windows 8 with python 3.6.1.
The purpose of the code is to clean some CSV files and write them concatenated into a single CSV file.In codenvy is working, but when running the code in windows the exit file gets blank lines between each Row, I want to know how to get around this:
import csv
import sys
import os
import glob
interesting_files = glob.glob("Vendas_artigos*")
with open('SaidaVendasArtigos.csv','wt',encoding='utf-8-sig') as fout:
for filename in sorted(interesting_files):
with open(filename,'rt',encoding='utf-8-sig') as fin:
next(fin)
reader = csv.reader(fin)
writer = csv.writer(fout)
for row in reader:
if row:
row.pop(0)
writer.writerow(row)
Python 3.5.1 in Codenvy:
row
row
row
Python 3.6.1 on Windows 8:
row
row
row
First, start by [tour] the site to understand how it works. In it you will find various materials on how to ask, including on formatting questions and answers. Second, try adding an indentation level to the last line
writer.writerow(row)
, making it written only if the line is not empty.– Woss
Oh yes, sorry, I will do the tour for now. Well, the level of identation in the last line did not work,tho.
– IGa
The result was the same?
– Woss
Sorry to keep you waiting,.
– IGa