No description
Find a file
2024-04-22 11:03:56 -06:00
src adding corrections to injection's rowTwelve, and a mongo parser to detect presence of existing wells in a mongodb database 2024-01-12 14:20:55 -06:00
tests initial commit 2023-11-23 16:48:58 -06:00
.gitignore initial commit 2023-11-23 16:48:58 -06:00
empower.png resizing again 2024-03-19 10:57:01 -06:00
LICENSE.md adding license 2024-03-19 12:42:21 -06:00
README.md adding small change to README 2024-04-22 11:03:56 -06:00
well_parser.nimble upgrading to version 0.2.1 2024-04-22 10:35:40 -06:00

Well parser

image

About

This project is intended to parse Texas Railroad Commission data provided in an unsuitable and non-transparent format. As of January 2024, this code is able to parse Drilling Permit Master and Trailer (Includes Latitudes and Longitudes) and Underground Injection Control Data

Future development of other datasets is not guaranteed due to time constraints.

Installation

You can install this by downloading the git, cd'ing to it and running

nimble install

or, when available through the Nim repository:

nimble install well_parser

Usage

You can either convert the data to json format or insert the data in MongoDB.

Drilling Permits

For drilling permits you can convert the data to json with the following code:

let jsonConversion = getDrillingData("/path/drilling_wells/daf420.dat.11-30-2023")
# and save file
jsonConversion.writeJson("/path/output.json")

To insert data to a MongoDb collection the following example may be used:

import well_parser, anonimongo, asyncdispatch

const 
    pathToFile = "/path/drilling_wells/daf420.dat.11-30-2023"
    URI = "mongodb://localhost:27017/"

var
   mongoDB = newMongo[AsyncSocket](MongoUri URI)
   localdb = mongoDB["texas-ccs"]
   col = localdb["drilling-permits"]
   iteration = 0

assert waitFor mongoDB.connect 
let s = getDrillingDataMongo(pathToFile)
for stuff in s:
    try:
        let insertM = waitFor col.insert(@[stuff])
        if not insertM.success:
            echo "Something went wrong!"
            break
    except MongoError:
        echo stuff
        quit()

If you require authentication, please refer to Anonimongo's documentation.

Injection wells

For Underground Injection Control Data converting to json differs slightly. As the file is one big flat file, json files are divided into chunks:

let sizeOfChunk = 500
getInjectionData("/path/to/uif700a.txt", "/directory/output/, sizeOfChunk)

this will create several jsons with a size of 500 elements.

To insert documents to MongoDB for the first time:

import well_parser, anonimongo, asyncdispatch

const 
    pathToFile = "/media/steamgames/uif700a.txt"
    URI = "mongodb://localhost:27017/"
    
var
   mongoDB = newMongo[AsyncSocket](MongoUri URI)
   localdb = mongoDB["texas-ccs"]
   col = localdb["injection-wells"]
   
assert waitFor mongoDB.connect
col.getInjectionDataMongo(pathToFile, false)

This will parse the entire file and insert every single injection well. If users wish to only update the collection the final argument of the getInjectionDataMongo proc needs to be changed to:

...
col.getInjectionDataMongo(pathToFile, true)

This will still traverse the entire file, but only insert new documents.