flat icon indicating copy to clipboard operation
flat copied to clipboard

[Feature Request] Support saving file in a new directory

Open tsekityam opened this issue 5 years ago • 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.

tsekityam avatar Oct 11 '21 10:10 tsekityam

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/[email protected]/fs/mod.ts";

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

Let me know if you tried something like that.

irealva avatar Oct 18 '21 15:10 irealva

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

irealva avatar Jan 18 '22 15:01 irealva

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

Staz avatar Feb 18 '22 08:02 Staz