Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@ import hmda.util.CSVConsolidator.{listDeDupeToList, stringDeDupeToList}
import io.chrisdavenport.cormorant.parser.CSVLikeParser
import io.chrisdavenport.cormorant

import scala.util.Try

object InstitutionCsvParser {
val parser: CSVLikeParser = new CSVLikeParser('|') {}

def apply(s: String): Institution = {
val values = cormorant.parser.parseRow(s, parser).toTry.get.l.map(_.x).toList
val activityYear = values.head.toInt
val lei = values(1)
val agencyCode = values(2).toInt
val institutionTypeCode = values(3).toInt
val agencyCode = Try(values(2).toInt).getOrElse(-1)
val institutionTypeCode = Try(values(3).toInt).getOrElse(-1)
val instId2017 = values(4)
val taxId = values(5)
val rssd = values(6).toInt
val rssd = Try(values(6).toInt).getOrElse(-1)
val emailDomains = values(7)
val respondentName = values(8)
val respondentState = values(9)
val respondentCity = values(10)
val parentIdRssd = values(11).toInt
val parentIdRssd = Try(values(11).toInt).getOrElse(-1)
val parentName = values(12)
val assets = values(13).toLong
val otherLenderCode = values(14).toInt
val topHolderIdRssd = values(15).toInt
val assets = Try(values(13).toLong).getOrElse(-1L)
val otherLenderCode = Try(values(14).toInt).getOrElse(-1)
val topHolderIdRssd = Try(values(15).toInt).getOrElse(-1)
val topHolderName = values(16)
val hmdaFiler = values(17)
val quarterlyFiler = values(18)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import hmda.parser.institution.InstitutionCsvParser
import io.circe.syntax._
import org.slf4j.LoggerFactory
import scala.concurrent.duration._
import hmda.auth.OAuth2Authorization
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}

import scala.concurrent.ExecutionContext
import scala.util.{ Failure, Success }
Expand All @@ -33,10 +35,10 @@ object InstitutionLoader extends App {
implicit val ec: ExecutionContext = system.dispatcher

def parallelism = config.getInt("hmda.loader.parallelism")
val url = config.getString("hmda.loader.institution.url")

val url = ""
val bankFilter = ConfigFactory.load("application.conf").getConfig("filter")
val token = ""

val bankFilterList =
bankFilter.getString("bank-filter-list").toUpperCase.split(",")

Expand Down Expand Up @@ -70,15 +72,15 @@ object InstitutionLoader extends App {
}

//- REQUEST WITH BEARER TOKEN
// def request(json: String) =
// postOrPut match {
// case "put" =>
// HttpRequest(uri = s"$url", method = HttpMethods.PUT)
// .withEntity(ContentTypes.`application/json`, ByteString(json)).addHeader((Authorization(OAuth2BearerToken(token))) )
// case _ =>
// HttpRequest(uri = s"$url", method = HttpMethods.POST)
// .withEntity(ContentTypes.`application/json`, ByteString(json)).addHeader((Authorization(OAuth2BearerToken(token))) )
// }
// def request(json: String) =
// postOrPut match {
// case "put" =>
// HttpRequest(uri = s"$url", method = HttpMethods.PUT)
// .withEntity(ContentTypes.`application/json`, ByteString(json)).addHeader((Authorization(OAuth2BearerToken(token))) )
// case _ =>
// HttpRequest(uri = s"$url", method = HttpMethods.POST)
// .withEntity(ContentTypes.`application/json`, ByteString(json)).addHeader((Authorization(OAuth2BearerToken(token))) )
// }


source
Expand Down
Loading