Created
April 24, 2016 20:25
-
-
Save thirdknife/1d6102a922db308571f91fcf5affcb16 to your computer and use it in GitHub Desktop.
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
def get_dataset(filehandle, start_dataset,end_dataset): # dataset_type : Dataset_01, Dataset_02, Dataset_03 or Dataset_04 | |
dataset = "" | |
with open(filehandle) as lines: | |
for num, line in enumerate(lines, 1): | |
if start_dataset in line: | |
start_pos = num | |
if end_dataset in line: | |
end_pos = num | |
lines = open(filehandle).readlines() | |
for x in range(start_pos, end_pos-1): | |
lines[x] = lines[x].replace(" ", "") | |
#lines[x] = lines[x].replace("\n", "") | |
if("#" not in lines[x] and lines[x][0] != "\n"): | |
dataset += lines[x] | |
return dataset.split("\n") | |
file_url = "datasets.txt" | |
start_d = 'D2' | |
end_d = 'D3' | |
print(get_dataset(file_url,start_d, end_d)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment