from pandas import read_table
def download_data(fileLocation, fields):
Downloads the data for this script into a pandas DataFrame. Uses columns indices provided
frame = read_table(
fileLocation,
# Specify the file encoding
# Latin-1 is common for data from US sources
encoding=latin-1,
#encoding=utf-8,# UTF-8 is also common
# Specify the separator in the data
sep=,,# comma separated values
# Ignore spaces after the separator
skipinitialspace=True,
# Generate row labels from each row number
index_col=None,
# Generate column headers row from each column number
header=0,# use the first line as headers
usecols=fields
)
# Return the entire frame
return frame
Reviews
There are no reviews yet.