Last active
January 27, 2021 04:38
-
-
Save juanarrivillaga/de0b3ba1ed641b0c3f926217222b53bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.read_csv('en_bigram.csv') | |
st = df[df["right"] == "some_text"]["left"] | |
st[st.str.startswith("My")].to_list() | |
# using a dict reader | |
import csv | |
result = [] | |
with open("en_bigram.csv") as f: | |
reader = csv.DictReader(f) | |
for row in reader: | |
if row["right"] == "some_text" and row["left"].startswith("My"): | |
result.append(row["left"]) | |
# alternatively, using a regular reader if you know the header: | |
import csv | |
result = [] | |
with open("en_bigram.csv") as f: | |
reader = csv.reader(f) | |
next(reader)# skip-header | |
for left, right in reader: # assuming you know the header | |
if right == "some_text" and left.startswith("My"): | |
result.append(left) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment