-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code changes to reflect data curation and cleanup results #16
Open
hlapp
wants to merge
3
commits into
NESCent:master
Choose a base branch
from
lsheble:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,13 @@ | |
>>> len(data_files) | ||
11 | ||
''' | ||
''' | ||
# ls note: deposit date ideally would have been 2005 for all datasets; when not indicated by repository, | ||
date of publication used (as per http://researchremix.wordpress.com/2011/02/16/choosing-repositories-for-the-tracking-data-reuse-project/: | ||
"In some repositories it is very difficult to determine the date of deposit. | ||
I use date of article publication as an imperfect proxy.") cf. Jonathan's notes (https://notebooks.dataone.org/data-reuse/links-to-our-data/) | ||
|
||
''' | ||
import csv | ||
import os | ||
import fnmatch | ||
|
@@ -15,14 +21,18 @@ | |
|
||
year_regex = re.compile('[(\[ ]([1-2][0-9]{3})[)\].]') | ||
|
||
data_files = fnmatch.filter(os.listdir('data/repo_datasets/'), | ||
'*_datasets.csv') | ||
# ls data_files = fnmatch.filter(os.listdir('data/repo_datasets/'), | ||
# ls '*_datasets.csv') | ||
|
||
data_files = fnmatch.filter(os.listdir('data/cleaner_old_all_datasets/'), | ||
'*.tsv') | ||
|
||
if __name__ == '__main__': | ||
print 'repo\tid\twos\tgs\tyear' | ||
|
||
for data_file in data_files: | ||
path = os.path.join('data/repo_datasets', data_file) | ||
# ls path = os.path.join('data/repo_datasets', data_file) | ||
path = os.path.join('data/cleaner_old_all_datasets', data_file) | ||
repo = clean_repo_name(data_file[:-len('_datasets.csv')]) | ||
with open(path) as input_file: | ||
r = csv.reader(input_file) | ||
|
@@ -43,9 +53,10 @@ | |
gs_col = gs_cols[0] | ||
except IndexError: | ||
gs_col = None | ||
|
||
date_cols = [n for n, x in enumerate(header) | ||
if 'date' in x.lower() or 'year' in x.lower()] | ||
# ls if 'date' in x.lower() or 'year' in x.lower()] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lsheble same as for other comment - would you mind deleting these |
||
if 'date made public' in x.lower()] | ||
|
||
try: | ||
assert len(date_cols) == 1 | ||
date_col = date_cols[0] | ||
|
@@ -57,6 +68,8 @@ | |
# if there's not a date column, try to parse it out of each | ||
# line with regular expressions | ||
date_col = None | ||
|
||
|
||
|
||
for line in r: | ||
if len(line) <= 1: continue | ||
|
@@ -69,6 +82,8 @@ | |
vals.append(wos) | ||
|
||
if gs_col is None: gs = 0 | ||
# ls: do we want to account for NA's like this? | ||
elif: gs_col == 'NA': gs = 0 | ||
else: | ||
gs = line[gs_col].split()[0] | ||
if not gs.strip(): gs = 0 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,11 @@ def main(file_path): | |
vals = line.split('\t') | ||
repo = vals[1] | ||
accession = vals[2] | ||
longest = sorted(vals, key=lambda k: len(k), reverse=True)[0].replace('\n', '').replace('\r', '') | ||
if longest.startswith('http'): continue | ||
if len(longest) < 100: continue | ||
# ls longest = sorted(vals, key=lambda k: len(k), reverse=True)[0].replace('\n', '').replace('\r', '') | ||
# ls if longest.startswith('http'): continue | ||
# ls if len(longest) < 100: continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lsheble same as for other comment - would you mind deleting these |
||
# article reference is in column 8 in the data table/spreadsheet that combines repos | ||
longest = vals[8] | ||
print '\t'.join((repo, accession, longest)) | ||
|
||
if __name__ == '__main__': | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsheble would you mind deleting these
# ls
lines. Git tracks and highlights the exact change already, and so not keeping a commented-out version of the changed line actually makes the diff much clearer for seeing quickly what changed.