File.FileManager (etl_core v0.1.55)

Tools for working with files

Summary

Functions

Returns text stored in a file

Load JSON into memory

Store in file, a text

Stores the data in a JSON file, a format supported for batch loading in BigQuery. The file name matches the time it was issued in UNIX format.

Functions

Returns text stored in a file

Parameters:

- path: String. File path.

Return:

- String
Link to this function

load_json(filename)

Load JSON into memory

Parameter:

- filename: String or String List indicating the path of files in JSON format to read

Examples:

eix> load_json("hello.json")
{word: "world"}

eix> load_json(["hello.txt", "foo.json"])
[{word: "world"}, {key: "bar"}]

eix> filename = "./file.txt" # fake file path
eix> load_json(filename)
{:error, :enoent}

eix> filename = "./file.txt" # misdefined JSON file
eix> load_json(filename)
{:error, %Poison.Parse{...}}
Link to this function

save(text, path)

Store in file, a text

Parameters:

- text: String: Text to put in the document.

- path: String. File path.
Link to this function

to_json_for_bigquery(data, path \\ ".")

Stores the data in a JSON file, a format supported for batch loading in BigQuery. The file name matches the time it was issued in UNIX format.

Parameters:

- data: List of map. Data.

- path: String. Local path to store the file.

Return:

- :ok | Exception