Currently use pearl to produce a table from a large amount of data and export to excel.
We are looking to switch to a python report system.
Looking for the best way to import/parse data from a .csv or .xls file into python, format that data, print the data in console and export formatted data into a spreadsheet. (By best I mean the simplest/slickest)
Want the ideal output % symbol is optional * can be changed for any other marker except a letter also want to do more with this data in python after export
thanks in advance for any help
something like this should do the job
for python3:
import csv
with open("output.csv","w",newline='') as f:
output = csv.writer(f)
for line in csv.reader(open("input.csv")):
for item in line[2:]:
#to skip empty cells
if not item.strip():
continue
item = item.split(":")
print([line[1]+item[0],item[1].rstrip("%")])
output.writerow([line[1]+item[0],item[1].rstrip("%")])
if using python2 replace the second line by
with open("output.csv","wb") as f:
Currently use pearl to produce a table from a large amount of data and export to excel.
We are looking to switch to a python report system.
Looking for the best way to import/parse data from a .csv or .xls file into python, format that data, print the data in console and export formatted data into a spreadsheet. (By best I mean the simplest/slickest)
Want the ideal output % symbol is optional * can be changed for any other marker except a letter also want to do more with this data in python after export
thanks in advance for any help
something like this should do the job
for python3:
import csv
with open("output.csv","w",newline='') as f:
output = csv.writer(f)
for line in csv.reader(open("input.csv")):
for item in line[2:]:
#to skip empty cells
if not item.strip():
continue
item = item.split(":")
print([line[1]+item[0],item[1].rstrip("%")])
output.writerow([line[1]+item[0],item[1].rstrip("%")])
if using python2 replace the second line by
with open("output.csv","wb") as f:
0 commentaires:
Enregistrer un commentaire