Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save OriHoch/087bc2ab49cb354009c1a021cf1ea5e9 to your computer and use it in GitHub Desktop.
Save OriHoch/087bc2ab49cb354009c1a021cf1ea5e9 to your computer and use it in GitHub Desktop.

Read data from exchange rates tap

Install the tap

pip install tap-exchangeratesapi

Write the tap configuration to exchangeratesapi-config.json

{
    "base": "ILS",
    "start_date": "2018-10-01"
}

Run the tap

import subprocess
import singer
from datapackage import Package
from dataflows import Flow, update_package, printer

def get_exchange_rates():
    p = subprocess.Popen(['tap-exchangeratesapi', '--config', 'exchangeratesapi-config.json'], stdout=subprocess.PIPE)
    for line in p.stdout:
        m = singer.parse_message(line).asdict()
        if m['type'] == 'RECORD':
            yield m['record']

Flow(
    get_exchange_rates(),
    printer(tablefmt='html')
).process()[1]

res_1

# BGN (number) CAD (number) BRL (number) HUF (number) DKK (number) JPY (number) ILS (number) TRY (number) RON (number) GBP (number) PHP (number) HRK (number) NOK (number) ZAR (number) MXN (number) AUD (number) USD (number) KRW (number) HKD (number) EUR (number) ISK (number) CZK (number) THB (number) MYR (number) NZD (number) PLN (number) CHF (number) SEK (number) CNY (number) SGD (number) INR (number) IDR (number) RUB (number)date (string)
10.4629 0.3518731.1093 76.45741.7646231.301 11.634991.103050.21083114.84771.759252.235813.889285.1036 0.3803460.274692305.3562.1502 0.23668130.60286.098088.856121.137230.4158951.0129 0.2701472.444911.886820.37639320.02834095.6518.01682018-10-01T00:00:00Z
20.4645830.3514421.0927476.83741.7711331.227111.648991.108630.21151414.88911.765312.242223.943475.145870.38199 0.274194306.5512.148370.23754130.80916.125718.875721.135560.4162431.019220.2697042.466031.883390.37678720.11974125.2417.92332018-10-02T00:00:00Z
30.4655890.3527981.0649976.861 1.7751131.297211.667771.110480.21161914.92061.768042.248273.952465.161470.3843650.274907307.8772.154360.23805631.16156.136838.9028 1.138120.4193821.022590.2716692.4709 1.888280.37827 20.16744142.5518.04012018-10-03T00:00:00Z
40.4672020.3535431.0777377.49991.7812631.367311.6847 1.116120.2116 14.92571.773452.260834.032615.233790.3877980.27476 310.1312.152640.23888 31.26946.158338.966841.139430.4229611.028880.2725382.484711.8873 0.37910320.21594168.1118.30992018-10-04T00:00:00Z
50.4680960.3557031.0582577.68661.7851931.360411.698411.1179 0.21101214.94781.776482.276894.062855.2367 0.3894020.275382310.7182.157320.23933831.37716.161039.033791.142840.4256381.030230.2736352.499591.891560.38030720.31584180.3 18.35022018-10-05T00:00:00Z
60.4680960.3557031.0582577.68661.7851931.360411.698411.1179 0.21101214.94781.776482.276894.062855.2367 0.3894020.275382310.7182.157320.23933831.37716.161039.033791.142840.4256381.030230.2736352.499591.891560.38030720.31584180.3 18.35022018-10-05T00:00:00Z
70.4680960.3557031.0582577.68661.7851931.360411.698411.1179 0.21101214.94781.776482.276894.062855.2367 0.3894020.275382310.7182.157320.23933831.37716.161039.033791.142840.4256381.030230.2736352.499591.891560.38030720.31584180.3 18.35022018-10-05T00:00:00Z
80.4700880.3584911.0357678.10121.7930331.272711.692921.121860.21153714.91431.784042.285374.100715.200340.3903860.27588 313.6092.160170.24035631.63086.186049.0917 1.146140.4277131.035480.2739092.510831.910880.38202120.43224198.2118.43712018-10-08T00:00:00Z
90.4699520.35709 1.0359278.16281.7923431.105111.6864 1.121540.21068314.90421.782932.280684.128675.219690.3893360.274768312.6172.152730.24028631.71786.200599.094841.142350.4273251.036960.27347 2.509671.902710.38107 20.44454201.6518.34912018-10-09T00:00:00Z
100.4689380.3574221.0284477.93661.7886931.225 11.675641.118280.20967214.93921.776682.265044.033935.261370.3885680.275733313.5562.160930.23976832.033 6.187699.078571.145130.4265951.0333 0.2736232.512771.909060.38132720.46674191.9718.26622018-10-10T00:00:00Z
110.4647370.3588541.0281877.21941.7727230.890611.649111.109040.20789414.86081.762432.258894.014785.251730.3876530.275045313.8252.155760.23762 31.93616.142 9.009121.1439 0.4241991.025730.2716 2.4741 1.900530.37945520.37864190.3118.27792018-10-11T00:00:00Z
120.4656670.3584291.0424877.17861.7762430.95 11.619521.109830.20866714.90021.764642.254173.976195.200810.3865710.275571311.7192.159430.23809532 6.137389.019521.144860.4230481.022290.2730952.4665 1.905790.37933320.27254190.0618.16662018-10-12T00:00:00Z
130.4656670.3584291.0424877.17861.7762430.95 11.619521.109830.20866714.90021.764642.254173.976195.200810.3865710.275571311.7192.159430.23809532 6.137389.019521.144860.4230481.022290.2730952.4665 1.905790.37933320.27254190.0618.16662018-10-12T00:00:00Z
140.4656670.3584291.0424877.17861.7762430.95 11.619521.109830.20866714.90021.764642.254173.976195.200810.3865710.275571311.7192.159430.23809532 6.137389.019521.144860.4230481.022290.2730952.4665 1.905790.37933320.27254190.0618.16662018-10-12T00:00:00Z
150.4655450.3590731.0354 76.99171.7759430.832411.591491.110970.20957614.91251.764662.251743.978225.193690.3863510.275666311.2542.160550.23803332.03926.140779.0074 1.145680.4218661.022160.2720242.473641.907480.37954320.34554192.8818.07242018-10-15T00:00:00Z
160.4631850.3554771.0187676.27241.7669430.768511.5884 1.105510.20744314.77351.756492.230863.909155.156920.3846770.274411308.3292.150530.23682732.161 6.1151 8.936181.138730.4169091.015750.2710242.443221.896860.37714620.15874161.2617.95432018-10-16T00:00:00Z
170.4648260.3554761.0241 76.65891.7730830.761 11.564261.1089 0.20901514.77831.762642.241023.9089 5.163680.38478 0.274028308.8412.147850.23766532.60776.141988.922431.137960.4174111.020530.2721982.451471.898640.37710320.17584156.6617.97952018-10-17T00:00:00Z
180.4655670.3572811.0105776.75021.7759530.812411.528011.111260.20910514.79141.766532.251853.9064 5.192770.3837030.27387 311.0172.146970.23804432.56456.156548.929521.138350.4171011.023330.2725842.459711.900430.37761 20.15884161.0417.97352018-10-18T00:00:00Z
190.4661440.3562461.0096577.03121.7781530.757711.538341.112210.20978614.68291.770742.252733.920665.217510.3828920.273375308.9142.143030.23833932.05666.165128.903881.136430.41421 1.025260.2722072.463431.894530.37657620.04984151.8817.93312018-10-19T00:00:00Z
200.4661440.3562461.0096577.03121.7781530.757711.538341.112210.20978614.68291.770742.252733.920665.217510.3828920.273375308.9142.143030.23833932.05666.165128.903881.136430.41421 1.025260.2722072.463431.894530.37657620.04984151.8817.93312018-10-19T00:00:00Z
210.4661440.3562461.0096577.03121.7781530.757711.538341.112210.20978614.68291.770742.252733.920665.217510.3828920.273375308.9142.143030.23833932.05666.165128.903881.136430.41421 1.025260.2722072.463431.894530.37657620.04984151.8817.93312018-10-19T00:00:00Z
220.4652460.3578671.0131376.86381.7746630.836411.548361.110160.21034514.71071.768042.252443.907185.276650.3850090.273419309.4222.143470.23788 32.16146.148728.961421.137 0.4161 1.020620.2725152.457541.898310.37715920.11184155.2217.85122018-10-22T00:00:00Z
{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment