I have a log file with data inside.
I would like to convert this file into a CSV (Excel) file.
I use Eclipse and write in Jython (all latest versions) but when I try to import CSV files I always get this error:
ImportError: no module named csv.
Do you know why?
This is my program:
import csv
r = open('file.log')
w = open('newfile.csv','w')
writer = csv.writer(w)
for row in r.readlines():
writer.writerow(row.split())
r.close()
w.close()
Now I tried openCSV. The CSV file is created, but it is empty.
In fact, the problem comse from the writeAll
.
If I put writeNext
, only one line appears in the CSV file (that's normal), but with writeAll
, the file is empty.
Do you know how I can resolve my problems?
This is my program:
from au.com.bytecode.opencsv import *
from java.io import *
for line in open("out.log"):
try :
en = line.split(" ")
writer = CSVWriter(FileWriter("out.csv"))
writer.writeAll(en)
except : IOException