File.FileManager (etl_core v0.1.42)
Tools for working with files
Link to this section 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.
Link to this section Functions
Link to this function
load(path)
Returns text stored in a file
parameters
Parameters:
- path: String. File path.
return
Return:
- String
Link to this function
load_json(filename)
Load JSON into memory
parameter
Parameter:
- filename: String or String List indicating the path of files in JSON format to read
examples
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
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
Return:
- :ok | Exception