-
-
Save petrolmer/39b12187e710da7688d3 to your computer and use it in GitHub Desktop.
Logr - features
This file contains 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 sys | |
import os | |
import csv | |
filename = 'opportunity_history.csv' | |
infile = csv.DictReader(open(filename)) | |
stagehistory={} | |
for row in infile: | |
if row["Id"] == "Id": | |
continue | |
if row["OpportunityId"] not in stagehistory: | |
stagehistory[row["OpportunityId"]] = {} | |
stagehistory[row["OpportunityId"]][row["StageName"]] = 1 | |
filename = 'opportunity.csv' | |
infile = csv.DictReader(open(filename)) | |
outfilename = 'dataset.csv' | |
outfile = csv.DictWriter(open(outfilename, 'w'), [ | |
"Opportunity","ReachedStage1", | |
], extrasaction = 'ignore', quoting = csv.QUOTE_MINIMAL, delimiter = ',', lineterminator = '\n') | |
header = {} | |
for field in outfile.fieldnames: | |
header[field] = field | |
outfile.writerow(header) | |
line = {} | |
for row in infile: | |
if row["Id"] == "Id": | |
continue | |
closedate = row["CloseDate"] | |
if closedate < "2013-10-01" or closedate > "2014-12-31": | |
continue | |
line["Opportunity"] = row["Id"] + " " + row["Name"] | |
if "1 - Discovery" in stagehistory[row["Id"]]: | |
line["ReachedStage1"] = "yes" | |
else: | |
line["ReachedStage1"] = "no" | |
outfile.writerow(line) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment