ozydave Posted October 21, 2015 Posted October 21, 2015 Teachers here have been teaching python (python.org) installed on windows 7 PCs They now want to be able too from python open / read / write to excel. I assume I need to install another library file or something. I seen a few but they are for Linux installs. Any help would be great Cheers
bladedanny Posted October 21, 2015 Posted October 21, 2015 Would it be possible to use the built in csv library? or are they already created XLS files. 1
ozydave Posted October 21, 2015 Author Posted October 21, 2015 Cheers Bladedanny I did mention csv to them but they are wedded to the idea of excel [emoji37]
steveking Posted October 21, 2015 Posted October 21, 2015 Ask your teachers why? And keep asking until they give a sensible answer! Or in pseudo code: while answer is rubbish { answer < input("no, really, why do you want to do this? ") } I can't think of any reason to complicate reading/writing to files at school level by using Excel as it's filetype - this is at any level up to A level. OCR GCSE only ever wants to read/write from text files / CSVs in their coursework tasks (and CSVs are just text files, although using the csv module in python can make stuff easier, although I often just stick commas in my output). If it's more complicated data type Python has a pickle function which basically lets you dump anything into a file, and then read it back. And I mean anything! The problem is that it's not a straight forward text file so only really usable by Python If it's complicated enough to warrant an Excel document it probably wants to be inputting/outputting in another format (sql, bigger data files, anything!) But, if you teachers must use excel a quick google shows several libraries and this looks helpful http://www.simplistix.co.uk/presentations/python-excel.pdf but seriously, why?! I keep trying to convince my students to write the simplest, shortest, most neat programs they can for any problem... and this is going against that! I have one student who is able to turn "hello world" into about 150 lines of code, it's hard work trying to convince him that the simplest answer is the cleverest! 1
ozydave Posted October 21, 2015 Author Posted October 21, 2015 Cheers steveking love the pseudo code [emoji3] Found out today they are desperate to write to excel. The IT teachers raised it with each other 1 week ago. Oh but silly them didn't think to speak /ask me. I need to put a few coins in the crystal ball! It's is ocr nationals, not even seen the exact requirements so if it is just text files my foot is going down with a firm hand tomorrow
halbaradkenafin Posted October 22, 2015 Posted October 22, 2015 Cheers steveking love the pseudo code [emoji3] Found out today they are desperate to write to excel. The IT teachers raised it with each other 1 week ago. Oh but silly them didn't think to speak /ask me. I need to put a few coins in the crystal ball! It's is ocr nationals, not even seen the exact requirements so if it is just text files my foot is going down with a firm hand tomorrow If it's the same ones that my staff are doing then it's just plain text/csv that needs to be worked with. Just remind them that csv can open in Excel, not sure why they'd want to other than checking it's written to the file at all (and they could do that with a few lines of python anyway).
ozydave Posted November 11, 2015 Author Posted November 11, 2015 Just an update, Teacher comes to me and says 'I think we can just write to a text or CSV file' *Bangs head on desk* Cheers guys
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now