I've got a text file with EPA well information and they are coded by state. I want to break out each state into its own text file. Here is the code I'm working with:
from __future__ import print_function
import os, sys
import numpy as np
print(os.getcwd())
lines = [] #lines from file
with open('UCMR3_All.txt') as well_list:
for line in well_list:
if line == "AL":
#what goes here?
well_list_output = open(os.path.join('..','well_list_output.txt'),'w')
for line in lines:
well_list_output.write(line)
well_list_output.close()
Basically, I want to take a line that contains "AL" and output it to its own file. I've attempted to use lines.append(line)
but that doesn't seem to help. I'll certainly accept helpful nudges or guidance in lieu of the answer!