简体   繁体   English

我应该在哪里发布我的python代码?

[英]Where should I post my python code?

Today I needed to parse some data out from an xlsx file (Office open XML Spreadsheet). 今天我需要从xlsx文件解析一些数据(Office open XML Spreadsheet)。 I could have just opened the files in openoffice and exported to csv. 我本可以在openoffice中打开文件并导出到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) 我在网上搜索xlsx解析器,我发现的只是一个stackoverflow问题,问同样的事情: 解析和生成Microsoft Office 2007文件(.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. 它有134行代码用于解析和访问电子表格,以及54行单元测试代码。 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. 这当然只在我需要它的1个文件上测试,除了它在单元测试中的使用方式之外,现在还没有文档。 It uses zipfile, minidom, re and unittest, so perfectly portable and platform independent. 它使用zipfile,minidom,re和unittest,因此非常便携且独立于平台。

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. 由于我没有博客,并且我没有任何希望将其变成OfficeOpen XML的python库,我很想知道我应该在哪里发布这段代码。 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. 我打算在activestate上托管它,但是在向我发送激活邮件时页面仍然崩溃。 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. 我的第二个选择是codeproject,我写了一篇关于该文件的好文章。 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 所以我把它放在github上,任何看到和分支: 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. 我不想为python项目托管做所有的工作,所以那就是了。

Accepting the git answer, as that was the only thing that worked for me. 接受git的答案,因为这是唯一对我有用的东西。 And git rocks. 和git岩石。

Edit: Gah, lost my entire post at codeproject, and I did such a nice writeup. 编辑:Gah,在codeproject丢失了我的整个帖子,我做了这么好的写作。 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. 除非我决定稍后调整它。

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. Stack Overflow是一个wiki,人们在那里搜索问题并找到答案。 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. 话虽这么说,如果你想在这里发布,你会做的是打开一个与你的答案相关的问题,然后用你的答案回答你自己的问题。

GitHub would also be a great place to post this. GitHub也是发布此内容的好地方。 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. 然后,任何想要它们的人都可以使用这些更改。

If your code is short enough to copy and paste, you might want to post it as a Python recipe . 如果您的代码足够短,可以复制和粘贴,您可能希望将其作为Python配方发布 That site is a great resource for learning Python techniques and its best contents have been compiled into a book . 该站点是学习Python技术的绝佳资源,其最佳内容已编译成书

If your code is reusable as-is then you should post your Python code in the Python Package Index (pypi). 如果您的代码可以原样重用,那么您应该在Python包索引 (pypi)中发布您的Python代码。 Organize your source code, read this tutorial on how to write a setup.py for your package. 组织您的源代码, 阅读本教程 ,了解如何为您的软件包编写setup.py 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. 获得免费的pypi帐户并编写setup.py ,运行python setup.py register来声明包的名称并将其元数据发布到索引中。 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 s ource dist ribution. setup.py也可以上传你的包的源或二进制文件的PyPI,例如python setup.py sdist upload将建立和上传的S乌尔斯河DIST ribution。

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 . 一旦你的包是Python Package Index的一部分,其他Python程序员就可以使用easy_install your_package许多工具自动下载和安装它。

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. 因此,您可以获得一个免费的博客,只需输入您想要分享的内容,这样您就可以在需要时随时获得稳定的在线参考。

In general, CodeProject is a great place to post code as long as you're willing to write a small article about the code. 一般来说, CodeProject是一个发布代码的好地方,只要你愿意写一篇关于代码的小文章。 (One of the good things about CodeProject is that they do require some verbiage about the code.) The site gets an extraordinary amount of traffic, so anything you post there will be seen. (关于CodeProject的一个好处是它们确实需要对代码进行一些措辞。)该网站获得了非常多的流量,因此您在那里发布的任何内容都将被看到。

在我看来, Python Package Index是适合您的地方

May I humbly suggest my site; 我可以谦卑地建议我的网站; http://utilitymill.com . http://utilitymill.com It lets you not only post your Python code, but also makes it into a runnable web utility. 它不仅可以发布您的Python代码,还可以使其成为可运行的Web实用程序。

Users can collaberate on the code and write-ups, and it even gives you an automatic RESTful API for the utility for free. 用户可以对代码和文档进行协作,甚至可以免费为实用程序提供自动RESTful API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM