2014-04-23 Lab14

posted Apr 24, 2014, 5:36 AM by Samuel Konstantinovich   [ updated Apr 28, 2014, 6:48 AM ]
Given a CSV (comma separated value) file, make an HTML table from the values in the table. 

a csv file is any number of rows of values with commas between them.
value1,value2,value3, ...

so the file that contains:


is really this:

Just like yesterday's lab you can readlines() the file to get:
BigList = [ "121,9,33,4\n",  "12,42,99,87\n",  "15,0\n",  "22"]

Also like yesterday's lab you can the split()  each element to get the individual values. 

OneLine =BigList[0].split(',')

now OneLine contains: [ "121" , "9" , "33" , "4\n" ]

If you dont want the \n at the end, you can strip the OneLine before you split it.

Lab14 Overview:
1. Make your lab14 directory in your public_html folder
2. make your data file in the lab14 folder
3. make your py file, make sure it generates a blank website BEFORE you add more code. If there is an internal server error, you should not write ANY code beyond the 1st 3 lines.
4. Write your lab. (directions below)
5. Link it in your assignments.html.

LAB14:  Convert a CSV file to an HTML table. (the py file will generate a website on marge based on the CSV file in the same directory)


would make the table:
 943 12 
 fish    ape 

Use this file to test: (but change it later)
Wanda Spears,Fusce.dolor.quam@atarcuVestibulum.co.uk,Tue 19th 1948,Filot
Blake Copeland,molestie@nonlobortistuis.com,Sat 26th 2004,Cavallino
Xantha V. Hooper,ac.arcu@Quisqueimperdieterat.org,Tue 30th 1982,Olmen
Libby Sanchez,amet.consectetuer.adipiscing@atvelitCras.edu,Thu 28th 1983,Raurkela
Rebecca K. Leach,tincidunt.orci@risusNunc.ca,Tue 4th 2001,Ferrere
Whilemina G. Snow,et.eros@parturient.org,Mon 27th 1962,Lustin
Griffith T. Singleton,Nullam.nisl@placeratorci.org,Thu 16th 1964,Campomarino
Leroy Crosby,vulputate.lacus.Cras@nunc.co.uk,Wed 31st 1973,Amstelveen
Mia Noble,magna.a.tortor@risusDonecnibh.com,Wed 25th 1982,Montreal
Prescott T. Adams,amet.luctus.vulputate@auguescelerisque.edu,Mon 9th 1986,Pelago
George U. Dickerson,dolor@orciluctuset.org,Wed 18th 2009,Telde
Libby G. Welch,Aenean.egestas@semperetlacinia.net,Thu 24th 1977,Cuenca
Erin Peterson,velit.eu.sem@ametconsectetueradipiscing.com,Mon 9th 1947,Wiekevorst

FINALLY: use www.generatedata.com   to generate a random data set with 100 lines that has at least 5 columns. Be careful because we use ',' to separate, so you cannot have any ',' in your data!!!