Created
August 9, 2020 13:18
-
-
Save crayxt/a6eee6e101bcd7d3a4e42fe2a3afe0ad to your computer and use it in GitHub Desktop.
Read GSLIB files in Julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read GSLIB files in Julia. | |
# http://www.gslib.com/gslib_help/format.html | |
in_file = "C:\\Test\\test.gslib" | |
using CSV | |
using DataFrames | |
function read_gslib(gslib_file) | |
header = String[] | |
file = open(in_file) | |
header_row = readline(file) | |
nparams = parse(Int64, readline(file)) | |
for i in 1:nparams | |
param = split(readline(file))[1] | |
push!(header, param) | |
end | |
close(file) | |
#println(header) | |
CSV.read(gslib_file, skipto=nparams+3, header=header, delim=" ", ignorerepeated=true) |> DataFrame | |
end | |
df = read_gslib(in_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment