Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I post my python code?

Today I needed to parse some data out from an xlsx file (Office open XML Spreadsheet). I could have just opened the files in openoffice and exported to csv. However I will need to reimport data from this spreadsheet later, and I wanted to eliminate the manual operation.

I searched on the net for xlsx parser, and all I found was a stackoverflow question asking the same thing: Parsing and generating Microsoft Office 2007 files (.docx, .xlsx, .pptx)

So I rolled my own.

It's 134 lines of code for the parsing and accessing off a spreadsheet, and 54 lines of code of unit tests. This of course is only tested on the 1 file I needed it, and aside from how it's used in the unit tests there are is no documentation as off now. It uses zipfile, minidom, re and unittest, so perfectly portable and platform independent.

Since I don't blog, and I don't have any desire to turn this into a python library for OfficeOpen XML, I am stuck wondering where I should post this code. I have solved a problem that I am sure others will get in the future. So I want to post my code under public domain somewhere for anyone to copy and paste into their app and adjust to fix their problem.

The implementation is simple, and here is a quick overview off the features:

workbook = Workbook(filename) # open a file
for sheet in workbook: pass # iterate over the worksheets
workbook["sheetname"] # access a sheet by name, also possible to do by index from 0
sheet["A1"] # Access cell
sheet["A"] # Access column
sheet["1"] # Access row
cell.value # Cell value - only tested with ints and strings.

Thanks for all the replies. I was going to hoste it on activestate, but the page kept crashing when sending me the activation mail. So I can't activate my code to post it.

My second choice was codeproject, and I wrote up a nice article about the file. Sadly that page crashes when I try to submit my post.

So I put it on github for any to see and branch off: http://github.com/staale/python-xlsx/tree/master

I don't want to do all the work for the python project hosting, so that's out.

Accepting the git answer, as that was the only thing that worked for me. And git rocks.

Edit: Gah, lost my entire post at codeproject, and I did such a nice writeup. Screw it, I have spent more time trying to share this than it took coding it. So I am calling it done for my part as off now. Unless I decide to tweak it more later.

like image 704
Staale Avatar asked Feb 17 '09 14:02

Staale


4 Answers

GitHub would also be a great place to post this. Especially as that would allow others to quickly fork their own copies and make any improvements or modifications they need. These changes would then also be available to anyone else who wants them.

like image 108
Sebastian Celis Avatar answered Nov 03 '22 21:11

Sebastian Celis


You should post it here. There are plenty of recipes here and yours would fit in perfectly.

Stack Overflow is meant to be a wiki, where people search for questions and find answers. That being said, if you want to post it here, what you would do is open a question relevant to your answer, then respond to your own question with your answer.

like image 26
ryeguy Avatar answered Nov 03 '22 21:11

ryeguy


If your code is short enough to copy and paste, you might want to post it as a Python recipe. That site is a great resource for learning Python techniques and its best contents have been compiled into a book.

If your code is reusable as-is then you should post your Python code in the Python Package Index (pypi). Organize your source code, read this tutorial on how to write a setup.py for your package. Once you have your free pypi account and have written setup.py, run python setup.py register to claim your package's name and post its metadata to the index. setup.py can also upload your package's source or binaries to pypi, for example python setup.py sdist upload would build and upload the source distribution.

Once your package is a part of the Python Package Index, other Python programmers can download and install it automatically with a number of tools including easy_install your_package.

like image 2
joeforker Avatar answered Nov 03 '22 21:11

joeforker


err, with a more descriptive title, i am sure many people would have found it here itself.(but i wasn't aware of the not-a-question tag).

Hence, you can get a free blog, and just put in the bits you want to share, that way you would also have a steady online reference whenever you need it.

like image 1
Sujoy Avatar answered Nov 03 '22 22:11

Sujoy