| 
            
              
            
         | 
         The Python Book
     | 
    
      
      |    | 
      
Cut and paste python on the command line
Simple example: number the lines in a text file
Read the file 'message.txt' and print a linenumber plus the line content. 
python - message.txt <<EOF
import sys
i=1
with open(sys.argv[1],"r") as f:
  for l in f.readlines():
    print i,l.strip('\n')
    i+=1
EOF 
Output: 
1 Better shutdown your ftp service. 
2 
3 W.  
Create a python program that reads a csv file, and uses the named fields
TBD. 
Use namedtuple 
Also see districtdatalabs.silvrback.com/simple-csv-data-wrangling-with-python 
 
       |   |