ictr / covid19-outbreak-simulator

Population-based Forward-time Simulator for the Outbreak of COVID-19
https://ictr.github.io/covid19-outbreak-simulator/
Other
1 stars 3 forks source link

reorganize sim output #10

Closed wuben2602 closed 4 years ago

wuben2602 commented 4 years ago

reorganizes text output of outbreak sim to csv file

BoPeng commented 4 years ago

Please first convert the script to a proper python program with command line options in the style of

def function_to_do_something(parameter):
    ...

if __name__ == '__main__':
    parser = argparse.ArgumentParser....
    args = ...
    function_to_do_something(args.whatever)
BoPeng commented 4 years ago

Seems not completed yet. Let me know when it is ready for review.

wuben2602 commented 4 years ago

I just rewrote the script to add the command line options

BoPeng commented 4 years ago

I wrote a few comments. I would suggest that you write a few functions to

  1. Identify time points (rows of the table)
  2. identify names with these time points (rows that can be converted)
  3. expand these rows to columns of the csv file depending on the values of these rows. proper column names need to be derived.

This will make your script easier to follow.

wuben2602 commented 4 years ago

This is my completed code as of 7/1. I adjusted the code quite a bit. The order of the columns are not the same as in the text file.

wuben2602 commented 4 years ago

These are my most recent changes as of 7/6. I didn't really understand how to get an argument to be '-' and I just tried to the best of my ability to allow an option to be the standard input. If you could clarify, that would be greatly appreciated.

wuben2602 commented 4 years ago

argparse doesn't accept the use of '-' as a parameter, so I had to use '-s'. If reorganize.py -s is called, then it'll read from standard input. With both input and standard input, standard output or file output can be chosen

BoPeng commented 4 years ago

I meant, either

script -i -

or

script --input -

or

script -

In the first two cases, the parameters should be

add_argument('-i', '--input')

as named parameter. In the last case, the parameter should be

add_argument('input')

as positional argument.

wuben2602 commented 4 years ago

changes as of 7/6