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
scala> import org.apache.spark.sql.functions.{input_file_name, udf} | |
import org.apache.spark.sql.functions.{input_file_name, udf} | |
scala> def extract_file_name(path: String): String = | |
| path.split("/").last | |
extract_file_name: (path: String)String | |
scala> spark.sqlContext.udf.register("extract_file_name", extract_file_name _); | |
res4: org.apache.spark.sql.expressions.UserDefinedFunction = UserDefinedFunction(<function1>,StringType,Some(List(StringType))) |
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
#expected format by morningstar | |
# Symbol,Quantity,Price,Action,TradeDate,Amount,Commission | |
# ABT,200,49.1475,Buy,8/31/2010,9836.5,7 | |
#current output format by Ally/Tradeking | |
# "Symbol","Description","Qty","Underl.Stock","CostBasis","Avg Price","Price<sup>*</sup>","Change","Change<br />%","TotalG/L","MarketValue","","", | |
# "AGN","Allergan Plc","10",,"$2,448.25","$244.83","$173.75","-$1.03","-0.59","-$710.75","$1,737.50","", | |
import csv | |
output_columns = "Symbol,Quantity,Price,Amount" |
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 csv | |
row = 'abc,xyz'.split(',') | |
print(row) | |
with open('eggs.csv','w') as csvfile: | |
spamwriter = csv.writer(csvfile, delimiter='|', | |
quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
spamwriter.writerow(row) |
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 logging | |
from tempfile import NamedTemporaryFile | |
from airflow.exceptions import AirflowException | |
from airflow.hooks.S3_hook import S3Hook | |
from airflow.models import BaseOperator | |
from airflow.utils.decorators import apply_defaults | |
class S3CopyOperator(BaseOperator): |
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
# With the credentials exported in the region | |
provider "aws" { | |
region = "us-east-1" | |
alias = "us-east-1" | |
} | |
provider "aws" { | |
region = "us-west-2" | |
alias = "us-west-2" |
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 axios from 'axios'; | |
const print_response = async (url: string) => { | |
console.log(`requesting url : ${url}`); | |
try { | |
const response = await axios.get(url, { | |
validateStatus: function (status) { | |
return status === 200; // default | |
} | |
}); |
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
interface TestInterface { | |
name: string, | |
description: string; | |
} | |
interface MyTestInterface extends TestInterface { | |
id: number; | |
} | |
const myEvent: MyTestInterface = { |