convert_import_file: Convert a raw importing file through process_fun

Description Usage Arguments Details Value See Also

Description

convert_import_file is the working horse backing process_files.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
convert_import_file(
  input_file,
  input_type = c("csv", "txt"),
  input_dir = NULL,
  start_index = 2L,
  ignore_problems = TRUE,
  log_dir = "./log",
  process_fun = NULL,
  ...,
  output_file = input_file,
  output_type = input_type,
  output_dir = input_dir
)

Arguments

input_file

A character of name or path of input data file, which could use regular expression to read multiple files into a combined dataframe, e.g. test[0-9]*.txt" will read files like test.txt, test1.txt,..., test9.txt..., etc., the files ware queued in ascending alphabet order.

input_type

A character of input file format, e.g. "txt", "csv".

input_dir

A path of working dir of input file, if NULL, use dir of input file as working dir, default NULL.

start_index

A integer of start index of first line of actual records in data file, by default 2L, which means first line is header and actual data starts from second line.

ignore_problems

A logic flag to determine whether to ignore problems when covert data, if TRUE, continue to import data but log problems into log file, otherwise abort reading process. By default TRUE.

log_dir

Path of log dir for saving problem log file, by default"./log", if the log path doesn't existed, it will be created.

process_fun

A function to process input file into output file.

...

Params to process_fun.

output_file

A name or a path of input data file.

output_type

A character of output file format, e.g. "txt", "csv".

output_dir

A path of working dir of output file, if NULL, use dir of output file as working dir, by default NULL,

Details

Convert a raw importing file into a processed importing file though three steps:

  1. Read import file into original dataframe by using read_import_file;

  2. Process original dataframe into processed dataframe by using process_fun, like ttm_financial_report;

  3. Write processed dataframe into file by using write_import_file.

Value

TRUE if success, else FALSE.

See Also

Other data management: clear_tables(), get_datasource(), import_table(), process_files(), read_import_file(), ttm_financial_report(), update_db(), write_import_file()


chriszheng2016/zstmodelr documentation built on June 13, 2021, 8:59 p.m.