gmshparser is a lightweight, 100 % tested and well documented package that aims to reliably parse the Gmsh ascii file format (.msh). The package does not introduce any external dependencies and thus fits well with the needs of your own FEM research code as a small stand-alone package.
I've noticed that gmshparser works only with .msh files saved in ASCII format 4. If I save the .msh file with ASCII format 2 I get the following error:
File "/opt/anaconda3/bin/gmshparser", line 8, in
sys.exit(main())
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/cli.py", line 38, in main
mesh = parse(args.filename)
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/init.py", line 14, in parse
parser.parse(mesh, io)
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/main_parser.py", line 29, in parse
parser.parse(mesh, io)
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/elements_parser.py", line 26, in parse
mesh.set_number_of_elements(meta[1])
IndexError: list index out of range
I've noticed that gmshparser works only with .msh files saved in ASCII format 4. If I save the .msh file with ASCII format 2 I get the following error:
File "/opt/anaconda3/bin/gmshparser", line 8, in
sys.exit(main())
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/cli.py", line 38, in main
mesh = parse(args.filename)
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/init.py", line 14, in parse
parser.parse(mesh, io)
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/main_parser.py", line 29, in parse
parser.parse(mesh, io)
File "/opt/anaconda3/lib/python3.8/site-packages/gmshparser/elements_parser.py", line 26, in parse
mesh.set_number_of_elements(meta[1])
IndexError: list index out of range