Editing Community Data Science Course (Sprint 2019)/Day 7 Notes

From CommunityData

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 20: Line 20:
      
      
  filehandle = open('~/Desktop/collisions.csv', 'w')
  filehandle = open('~/Desktop/collisions.csv', 'w')
  filehandle.write(response.text)
  filehandle.write(response.content())
  filehandle.close()
  filehandle.close()


Line 38: Line 38:
'''Code to open a file and print the first column'''
'''Code to open a file and print the first column'''
    
    
  file_handle = open('collisions.csv', 'r')  # open the csv file
  file_handle = open('sdot_collisions_seattle.csv', 'r')  # open the csv file
  for line in file_handle:                                # loop through the file one line at a time.
  for line in file_handle:                                # loop through the file one line at a time.
     line_clean = line.strip()                            # remove the newline character at end of line
     line_clean = line.strip()                            # remove the newline character at end of line
Line 50: Line 50:
(You'll want to open this window in a wide browser)
(You'll want to open this window in a wide browser)
    
    
  file_handle = open('collisions.csv', 'r')  # open the csv file
  file_handle = open('sdot_collisions_seattle.csv', 'r')  # open the csv file
  header = file_handle.readline()
  header = file_handle.readline()
  output_handle = open('collisions_transformed.csv', 'w')    # NOTE this will overwrite  
  output_handle = open('sdot_collisitions_transformed.csv', 'w')    # NOTE this will overwrite  
  for line in file_handle:                                # loop through the file one line at a time.
  for line in file_handle:                                # loop through the file one line at a time.
     line_clean = line.strip()                            # remove the newline character at end of line
     line_clean = line.strip()                            # remove the newline character at end of line
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see CommunityData:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)