Skip to content

Commit

Permalink
Merge pull request #232 from codeforsanjose/data-errors
Browse files Browse the repository at this point in the history
Update Scraper and fix bug with loan data
  • Loading branch information
rwalek668 authored Oct 8, 2021
2 parents 18f607d + 683ba5a commit 97426f4
Show file tree
Hide file tree
Showing 5 changed files with 34,254 additions and 27,291 deletions.
1 change: 1 addition & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apk update && apk add build-base autoconf automake libtool pkgconfig nasm
# Add the package.json file and build the node_modules folder
WORKDIR /app
COPY ./package*.json ./

RUN mkdir node_modules
RUN apk update && apk add yarn python g++ make && rm -rf /var/cache/apk/*
RUN yarn install
Expand Down
16 changes: 5 additions & 11 deletions data_pipeline/data_processing/aggregatedcsv2redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def read_data_sheet(self):
if "csv" in filetype:
self.data = pd.read_csv(
self.filename,
skiprows=lambda x: x % 2 == 1,
sep=",",
quotechar='"',
encoding="iso-8859-1",
Expand Down Expand Up @@ -327,16 +326,11 @@ def setCandidateShapeInRedis(self, electionDate="11/3/2020") -> bool:
.round(decimals=2)
.to_dict()
)
if "RCPT" in totalByRecType["Amount"]:
candidate["TotalRCPT"] = totalByRecType["Amount"]["RCPT"]
if "EXPN" in totalByRecType["Amount"]:
candidate["TotalEXPN"] = totalByRecType["Amount"]["EXPN"]
if "LOAN" in totalByRecType["Amount"]:
candidate["TotalLOAN"] = totalByRecType["Amount"]["LOAN"]
if "S497" in totalByRecType["Amount"]:
candidate["TotalS497"] = totalByRecType["Amount"]["S497"]
candidate["TotalFunding"] = candidate["TotalRCPT"] + candidate["TotalLOAN"]

candidate["TotalRCPT"] = totalByRecType["Amount"].get("RCPT", 0)
candidate["TotalEXPN"] = totalByRecType["Amount"].get("EXPN", 0)
candidate["TotalLOAN"] = totalByRecType["Amount"].get("LOAN", 0)
candidate["TotalS497"] = totalByRecType["Amount"].get("S497", 0)
candidate["TotalFunding"] = candidate.get("TotalRCPT", 0) + candidate.get("TotalLOAN", 0)
# Get funding by committee type
recpDataPerCandidate = dataPerCandidate[
dataPerCandidate["Rec_Type"].isin(["RCPT", "LOAN"])
Expand Down
Loading

0 comments on commit 97426f4

Please sign in to comment.