Skip to content

Instantly share code, notes, and snippets.

@psy901
Created January 18, 2018 11:00
Show Gist options
  • Save psy901/5aa480290ef47f10552a26ea5f714bc7 to your computer and use it in GitHub Desktop.
Save psy901/5aa480290ef47f10552a26ea5f714bc7 to your computer and use it in GitHub Desktop.
Importing columns from csv file
import pandas as pd
def read_csv(filename, num_rows):
# print("")
df = pd.read_csv(filename, encoding='latin-1', nrows=num_rows)
table = df[['Name', 'Country']]
search_terms = []
# getting columns of name and country
for index, row in table.iterrows():
name = row['Name']
country = row['Country']
search_terms.append(name + " " + country)
return search_terms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment