LucjanJanowski / translator-to-suJSON

Read subjective experiment data to suJSON format.
MIT License
2 stars 1 forks source link

Repackage python program #11

Closed slhck closed 5 years ago

slhck commented 5 years ago

This addresses a couple of things.

Now, eveything lives in a sujson package. It can be installed with pip3 install . and you can then call sujson from the command line.

As for code layout: The __main__.py code is responsible for all things that have to do with the command line. The _sujson.py code with its Sujson class instead is only responsible for actual data processing. That means in the future someone could just import the Sujson class and do transformations without going through CLI. Hence, it's important that the Sujson class takes all necessary configuration via arguments passed to its functions. As you can see, the class can "remember" stuff that may be useful for different calls. For example, you may read in some data, transform it, and output it multiple times in different formats.

Ideally, in the future, the configuration could be moved out of the config file and into function arguments. For example, the import_xslx function should have an option to specify sheet_hdr_name etc.

Example run:

python3 -m sujson ingest example/data/its4s_subjective_data.xlsx -c example/config/config.json.for_its4s.json

Some additional info:

slhck commented 5 years ago

You will note that the import_xslx code is mostly unchanged, so you can add your logic there. The same goes for import_csv. Ideally there should not be a lot of repetition in these two functions.

PS: Why "ingest"? Since import is a reserved Python name :)

Qub3k commented 5 years ago

Sounds great @slhck, thank you! Let me take a look at it and merge it with the master branch. 😊

slhck commented 5 years ago

Great!

I will work on the “export to CSV” function and some general usability stuff (like configuration) once it's merged. I'm thinking about providing better defaults as well, so you don't have to write too large config files. I think it would be best if we also started to collect more working examples that we can provide.

slhck commented 5 years ago

Closed in favor of #12