Created
April 24, 2016 19:35
-
-
Save thirdknife/cb5ce4e58a062b534476f7d891c0996f to your computer and use it in GitHub Desktop.
This file contains hidden or 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]): | |
| dataset += lines[x] | |
| return dataset | |
| 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