While trying to upgrade a python2 flask app, I discovered csvjson doesn't (to my knowledge) have any direct method/constructor that allows you to submit address of an input filename (input_path) for instance from within a python file rather than a cli.
Does something already exist for CSVJSON to accept input_path at initialisation of the class? If not, then any chance of adding that in? I currently modified csvjson for myself like this.
#csvjson.py
def __init__(self, args=None, output_file=None):
super(CSVJSON, self).__init__(args, output_file)
#Added this to ensure there was an input file
self.input_file = args[0]
self.validate_args()
self.json_kwargs = {
'ensure_ascii': False,
'indent': self.args.indent,
}
...
...
and from my flask app, I initialise simply as this:
def create_json_from_csv(in_name, out_name):
#in_name and out_name are both file paths
args = [in_name]
out_file = open(out_name, "w", encoding="utf-8")
CSVJSON(args, out_file).main()
out_file.close()
While trying to upgrade a python2 flask app, I discovered csvjson doesn't (to my knowledge) have any direct method/constructor that allows you to submit address of an input filename (input_path) for instance from within a python file rather than a cli.
Does something already exist for CSVJSON to accept input_path at initialisation of the class? If not, then any chance of adding that in? I currently modified csvjson for myself like this.
and from my flask app, I initialise simply as this: