[Tutor] Translating R Code to Python-- reading in csv files, writing out to csv files

Joel Goldstick joel.goldstick at gmail.com
Sun May 20 14:44:25 CEST 2012


On Sun, May 20, 2012 at 6:30 AM, Massimo Di Stefano
<massimodisasha at gmail.com> wrote:
> Maybe this doc.
>
> http://mathesaurus.sourceforge.net/matlab-python-xref.pdf
>
> can help ?
>
> i found it useful.
>
> Massimo.
>
>
> Il giorno May 20, 2012, alle ore 2:42 AM, Martin A. Brown ha scritto:
>
>>
>> Benjamin,
>>
>> : Thanks Martin-- this is really great.  My major question now is
>> : that I need to transition to Python for a project and I need to
>> : learn how to think in Python instead of in R.  The two strategies
>> : I have used so far are: a) going through the description and
>> : exercises in  http://www.openbookproject.net/thinkcs/python/english2e/
>> : and b) trying to convert my R code into Python.
>>
>> I haven't seen that before, but, of course, there ar scads of
>> resources out there for anybody learning these days.
>>
>> : On a high-level, do you have any other suggestions for how I
>> : could go about becoming more proficient in Python?
>>
>> Well, here is my list.  Others probably have some suggestions, too:
>>
>>  * solve a specific and immediate real problem in Python, but solve
>>    the problem as generally as possible; apply
>>
>>  * lurk here (and on other lists) and watch how experienced Python
>>    practitioners help others face a problem in Python; absorb
>>
>>  * join domain-specific Python groups that discuss libraries,
>>    tools or techniques that apply in your area of interest; inquire
>>
>>  * learn Python's common datatypes well, you will encounter them
>>    often: str, int, float, list, dict, set; study
>>
>>  * learn Pythonic programming idioms, and, importantly, learn
>>    why they are considered Pythonic (that will give you insight
>>    into thinking in Python); gain relevant experience
>>
>>  * browse the standard library occasionally to learn a new module
>>    http://docs.python.org/py-modindex.html
>>
>>  * learn how to make modules; build your code into modules (if
>>    appropriate and where possible)
>>
>>  * read a book (lots of options here); I'm a 'learn by example'
>>    sort so I liked the O'Reilly _Python Cookbook_ [0]
>>
>>  * read PEP 8 http://www.python.org/dev/peps/pep-0008/
>>
>> Good luck and enjoy Python,
>>
>> -Martin
>>
>> [0] http://shop.oreilly.com/product/9780596007973.do
>>
>> --
>> Martin A. Brown
>> http://linux-ip.net/
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor


So, with the example file you showed previously, sit down and write
some code.  It probably will take less than a screen size full of code
-- maybe 20 lines or so.  See what you get for output.  You will
certainly get errors -- syntax and runtime.  When you get stuck, cut
and paste the code and the trace-back that python gives you to your
email, and people will help you move forward.




-- 
Joel Goldstick


More information about the Tutor mailing list