We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this questionI had a txt file with content as shown below: 'marks: 40,66,34,88,70' i want to make a spread sheet with the content of txt file. (illustrated with refer开发者_开发问答rence to 1 txt file, supposing to handle many). is there any module to handle spreadsheets? how can i achieve this?
The csv
module can export in a format that can be read by nearly all spreadsheet programs with little difficulty. It's not really clear from your question what you want to put in such a file, though.
http://sourceforge.net/projects/pyexcelerator/
can be used to create Excel files easily. Check out the examples from the examples folder within the source tree.
My personal preference:
For writing Excel Files
For Reading Excel Files
Just go here.
This uses pypi. So it's even better!
The csv module can do your spreadsheet lifting.
Assuming you have the file contents read in, here is the relevant spreadsheet creation:
import csv
outfile = open('output.csv', 'wb')
# Done for example, a list will need to be created for each row of your spreadsheet.
filecontents = [marks,40,66,34,88,70]
fileWriter = csv.writer(outfile, dialect='excel')
fileWriter.writerow(filecontents)
outfile.close()
Of course, there will be additional reading files and loops to write more than one row to the csv file, this is just a basic example.
精彩评论