diff options
author | David Luevano <55825613+luevano@users.noreply.github.com> | 2019-12-08 21:54:19 -0700 |
---|---|---|
committer | David Luevano <55825613+luevano@users.noreply.github.com> | 2019-12-08 21:54:19 -0700 |
commit | 7c8b391dddd65ff58417df80dfc79cadddf4f4e6 (patch) | |
tree | 0bad908f5b40848addc3307de4307b1dae4c6e7e /read_nc_data.py |
First commit
Diffstat (limited to 'read_nc_data.py')
-rw-r--r-- | read_nc_data.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/read_nc_data.py b/read_nc_data.py new file mode 100644 index 000000000..b00cd4dba --- /dev/null +++ b/read_nc_data.py @@ -0,0 +1,22 @@ +# 'periodic_table_of_elements.txt' retrieved from +# https://gist.github.com/GoodmanSciences/c2dd862cd38f21b0ad36b8f96b4bf1ee + + +def read_nc_data(data_path): + """ + Reads nuclear charge data from file and returns a dictionary. + data_path: path to the data directory. + """ + fname = 'periodic_table_of_elements.txt' + with open(''.join([data_path, '\\', fname]), 'r') as infile: + temp_lines = infile.readlines() + + del temp_lines[0] + + lines = [] + for temp_line in temp_lines: + new_line = temp_line.split(sep=',') + lines.append(new_line) + + # Dictionary of nuclear charge. + return {line[2]: int(line[0]) for line in lines} |