azure-vm-pricing icon indicating copy to clipboard operation
azure-vm-pricing copied to clipboard

Create output options

Open itTkm opened this issue 4 years ago • 3 comments

Hi @gabrielweyer

Thank you for your great app!!

I have added new options for parser.

Reasons:

  • I need JSON file only.
  • I want to change output filename by argument (as bellow)
    ./out/japan-east_windows_USD.json
    ./out/japan-east_windows_JPY.json
    

itTkm avatar Oct 23 '20 09:10 itTkm

Thank you for your contribution. I'm trying to understand your use case.

Do you want to add the currency to the file name because you're parsing the same Azure region and operating system using multiple currencies? Hence running the parser multiple times overrides the output of the previous runs?

What's the reasoning behind wanting only either JSON or CSV output?

gabrielweyer avatar Oct 27 '20 20:10 gabrielweyer

Do you want to add the currency to the file name because you're parsing the same Azure region and operating system using multiple currencies? Hence running the parser multiple times overrides the output of the previous runs?

In case of above example, your understand is right. But above example is just simple use case for understanding easily.

In may actually use case is below. I want to execute below script with timer.

#!/bin/bash

OUTPUT_DIR=rateCards
TIMESTAMP=`date +%Y%m%d-%H%M%S`

mkdir -p $OUTPUT_DIR

REGIONS='["japan-east", "japan-west"]' # Actually there are many more regions
CURRENCYS='["JPY", "USD"]' # Actually there are many more currencys

REGIONS_LEN=$(echo $REGIONS | jq length)
for i in $( seq 0 $(($REGIONS_LEN - 1)) ); do
  REGION=$(echo $REGIONS | jq -r .[$i])

  CURRENCYS_LEN=$(echo $CURRENCYS | jq length)
  for j in $( seq 0 $(($CURRENCYS_LEN - 1)) ); do
  CURRENCY=$(echo $CURRENCYS | jq -r .[$j])
    yarn crawl \
      --culture en-us \
      --currency ${CURRENCY} \
      --operating-system windows \
      --region ${REGION} \
      --output-filename $OUTPUT_DIR/${TIMESTAMP}_${REGION}_windows_${CURRENCY}.json \
      --output-json-only
    yarn crawl \
      --culture en-us \
      --currency ${CURRENCY} \
      --operating-system linux \
      --region ${REGION} \
      --output-filename $OUTPUT_DIR/${TIMESTAMP}_${REGION}_linux_${CURRENCY}.json \
      --output-json-only
  done
  
done

What's the reasoning behind wanting only either JSON or CSV output?

In above use case, file counts will increment by each execution. On the other hand the storage size has limit. So I want to get only JSON file for my other system.

itTkm avatar Oct 28 '20 01:10 itTkm

Thank you for clarifying your use case. May I recommend an alternative approach which I think satisfies you requirements while keeping the changes minimal for the other users?

I think it makes sense to add the currency to the file name by default. The file name is being constructed using the below template:

vm-pricing_${region}_${operatingSystem}

Instead we could use:

vm-pricing_${region}_${operatingSystem}_${currency}

Once you're done running the parser, you can then delete all the CSV files and move the JSON files to a directory of your choice (it looks like you're organising them by date).

gabrielweyer avatar Oct 31 '20 00:10 gabrielweyer