Skip to content

Instantly share code, notes, and snippets.

@crayxt
Created August 9, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crayxt/a6eee6e101bcd7d3a4e42fe2a3afe0ad to your computer and use it in GitHub Desktop.
Save crayxt/a6eee6e101bcd7d3a4e42fe2a3afe0ad to your computer and use it in GitHub Desktop.
Read GSLIB files in Julia
# 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