From f94ee80636338f55a9caf129abbf6e07daa2ea5e Mon Sep 17 00:00:00 2001 From: David Bold Date: Tue, 8 Oct 2024 09:20:12 +0200 Subject: [PATCH] Revert deletion of file_import --- src/boututils/file_import.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/boututils/file_import.py diff --git a/src/boututils/file_import.py b/src/boututils/file_import.py new file mode 100644 index 000000000..34d35544d --- /dev/null +++ b/src/boututils/file_import.py @@ -0,0 +1,27 @@ +"""Import an entire BOUT++ DataFile into memory + +""" + +from boututils.datafile import DataFile + + +def file_import(name): + """Read all variables from file into a dictionary + + Parameters + ---------- + name : str + Name of file to read + + Returns + ------- + dict + Dictionary containing all the variables in the file + """ + f = DataFile(name) # Open file + varlist = f.list() # Get list of all variables in file + data = {} # Create empty dictionary + for v in varlist: + data[v] = f.read(v) + f.close() + return data