githubocto/flat

[Feature Request] Support saving file in a new directory

tsekityam opened this issue · 3 comments

What did I do

I setup a repo to collect holdings of ARK funds using flat. The repo is up and running.

However, the holding csv downloaded from https://ark-funds.com contains a line of disclosure at the end of the files. I would like to remove the line by applying a postprocessing script to the raw file.

I tried to save the files downloaded from https://ark-funds.com to raw/ARK_INNOVATION_ETF_{fund}_HOLDINGS.csv, and then use the script to remove the disclosure from the raw file, and save the cleared file in ARK_INNOVATION_ETF_{fund}_HOLDINGS.csv.

Here is the GitHub Action config I used:

      - name: Fetch data
        uses: githubocto/flat@v3
        with:
          http_url: https://ark-funds.com/wp-content/uploads/funds-etf-csv/ARK_INNOVATION_ETF_ARKK_HOLDINGS.csv
          downloaded_filename: raw/ARK_INNOVATION_ETF_ARKK_HOLDINGS.csv
          axios_config: query.json
          postprocess: ./postprocess.js

What did I see

GitHub Action execution failed because of Error: ENOENT: no such file or directory, open 'raw/ARK_INNOVATION_ETF_ARKK_HOLDINGS.csv'

What do I want

The file can be created successfully. The action should help me to create the raw directory if it is not exist.

Hi there, sorry for the delay. Have you tried using Deno commands to check for the existence of the directory and/or create one if not?

From the Deno docs:

"Ensures that the directory exists. If the directory structure does not exist, it is created. Like mkdir -p."

import {
  ensureDir,
  ensureDirSync,
} from "https://deno.land/std@0.78.0/fs/mod.ts";

ensureDir("./bar"); // returns a promise
ensureDirSync("./ensureDirSync"); // void

Let me know if you tried something like that.

Closing for lack of activity. Not really sure this is a bug.

Staz commented

I had this issue too @tsekityam. The only way I could fix it was to manually create the target directories and commit them.