1import csv
2import requests
3
4CSV_URL = 'http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv'
5
6with requests.Session() as s:
7 download = s.get(CSV_URL)
8
9 decoded_content = download.content.decode('utf-8')
10
11 cr = csv.reader(decoded_content.splitlines(), delimiter=',')
12 my_list = list(cr)
13 for row in my_list:
14 print(row)
1data = pd.read_csv(
2 "data/files/complex_data_example.tsv", # relative python path to subdirectory
3 sep='\t' # Tab-separated value file.
4 quotechar="'", # single quote allowed as quote character
5 dtype={"salary": int}, # Parse the salary column as an integer
6 usecols=['name', 'birth_date', 'salary']. # Only load the three columns specified.
7 parse_dates=['birth_date'], # Intepret the birth_date column as a date
8 skiprows=10, # Skip the first 10 rows of the file
9 na_values=['.', '??'] # Take any '.' or '??' values as NA
10)
1import pandas as pd
2import io
3import requests
4url="https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv"
5s=requests.get(url).content
6c=pd.read_csv(io.StringIO(s.decode('utf-8')))
7