1 / 23

Perl R and SQL for the very beginners

Perl R and SQL for the very beginners. Christoph Rau, Calvin Pan and Yehudit Hasin Dec 2011. What we do and do not intend to teach. DO. DO NOT. Make you change career to a programmer Replace self – learning process Make you an expert. Get you started as painlessly as possible

davida
Download Presentation

Perl R and SQL for the very beginners

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Perl R and SQL for the very beginners Christoph Rau, Calvin Pan and Yehudit Hasin Dec 2011

  2. What we do and do not intend to teach DO DO NOT Make you change career to a programmer Replace self – learning process Make you an expert • Get you started as painlessly as possible • Make you able to write simple, usable and sustainable code for yourself • Make you comfortable to expand your knowledge on your own • Give you the right address(es) for asking questions

  3. Dates • 12/8 – Introductions + Perl1 - Yehudit • 12/15 – Perl 2 – Yehudit • 12/22-12/29 – NO MEETINGS • 1/5 – Perl 3 – Yehudit • 1/12 – Perl 4 – Yehudit • 1/19 – R 1 - Christoph • 1/26 – R2 - Christoph • 2/2 – R3 – Christoph • 2/9 – SQL1 - Calvin • 2/16 –SQL2 - Calvin

  4. http://xkcd.com/519/

  5. Today • Introduction • Why Perl/R/SQL? • What is a programing language? • GPP – good programming practice • Perl 1 • My first program • Data types • Data organization • Simple operators

  6. Why Perl/R/SQL and not Excel? • Responsibility • More work • Safety • Flexibility • Speed • Reproducibility

  7. Why Perl& R& SQL? Perl Manipulation of LARGE data files Text patterns Fast R SQL Statistical analysis Graphing capabilities Analysis packages Efficient data storage and retrieval

  8. What is “programming” and why it is a language? “Language” – The words, their pronunciation, and the methods of combining them used and understood by a community A body of words and the systemsfor their use common to a people who are of the same community or nation, the same geographical area, or the same cultural tradition: the two languages of Belgium; a Bantu language; the French language; the Yiddish language. The system of linguistic signs or symbols considered in the abstract. Any set or system of such symbols as usedin a more or less uniform fashion by a number of people, who are thus enabled to communicate intelligibly with one another. Any system of formalized symbols, signs, sounds, gestures, or the like used or conceived as a means of communicating thought, emotion, etc.

  9. Adapt your thinking • Personal interpretation • Associative thinking • Initiative • Learning from past experience Computer does EXACTLY and EVERYTHING you tell it to

  10. What is wrong with that program? “I would like you to clean my desktop” Clean (desktop);

  11. What is wrong with that program? • “Go to desktop folder” • “For each file examine if it has the words “data”, when it was last opened and size” • If opened more than a year ago and is smaller than 1Mb and does not contain the word “data” – delete.

  12. Why Perl/R/SQL and not Excel? • Responsibility • More work • Safety • Flexibility • Speed • Reproducibility

  13. Good Programming Practice or super fast safety course

  14. When you cut out the middle man

  15. Good Programming Practice Good Bad and ugly • Have a dedicated folder to optimize your scripts • Have a small file, with similar structure to the data file, to test your script (usually just get sample rows). • Give meaningful names to scripts, variables, files etc… • Document your code • Backup, backup………really BACKUP • Run scripts in any directory higher than Desktop • Optimize your script on a REAL data file • Use “temp”, “x”, “David1” or similar for naming • Assume that your script is perfect

  16. Beginning Perl Chapter1

  17. Perl – “Beginning Perl”(Simon Cozens, Peter Wainwright) Resources The main perl website http://www.perl.org/ The book I use as scaffold …/books/beginning-perl/ Very good documentation for all perl functions http://perldoc.perl.org/ The best forum about perl for all levels http://www.perlmonks.org/ For modules and their documentation: http://www.cpan.org/

  18. What I hope to cover • Data types • Data structures – variable, array, hash • Loops and conditional statements – “if”, “for”, “foreach”, “while”, “unless” etc….. • Open, read write and close files • Functions – modules, subroutines • Regular expressions

  19. Perl scripts are simple text files #!/usr/bin/perl use strict; use warnings; print "Hello!!!! :)))"; Get a free editor – the one you will like better Macs: Text Wrangler (simpler) or Komodo…. Windows: Padre, Komodo…..

  20. Tells perl to be more verbal about mistakes in code Tells unix where perl resides #!/usr/bin/perl –w use strict ; use warnings ; print "Hello!!!! :)))\n” ; End of statement Quotations mean it is a string Keyword (a word that is in perl vocabulary, in this case function)

  21. Perl - types of Data Data can be a number or a string Data can be organized in scalar – a single value list – can hold multiple values Perl special signs: $xx= variable – can hold any one value (scalar) @xx= array – can hold multiple values (list).

More Related