Skip to content

Lint .tsv #86

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

Merged
merged 1 commit into from
Apr 19, 2021
Merged

Lint .tsv #86

merged 1 commit into from
Apr 19, 2021

Conversation

kousu
Copy link
Contributor

@kousu kousu commented Apr 18, 2021

Fixes #57 (comment)

This can detect three problems:

  • an incorrect number of fields
  • a fully empty field (because nulls should be "-")
  • trailing whitespace

It doesn't directly detect using spaces instead of tabs, but if you do that you'll probably trip the incorrect count or the trailing whitespace detector.

Example usage: After intentionally corrupting participants.tsv in each of the three ways:

$ .github/workflows/lint-tsv participants.tsv 
extraneous whitespace, line 2, column 4: '2019-02-12   '
errors in line 2: 
	'sub-amu01	M	28	2019-02-12   	amu	AMU - CEMEREM	Siemens	Verio	NeckMatrix	syngo_MR_B17	Virginie Callot'

empty field, line 3, column 7. Please use '-' for null values.
errors in line 3: 
	'sub-amu02	M	28	2019-02-13	amu	AMU - CEMEREM		Verio	NeckMatrix	syngo_MR_B17	Virginie Callot'

empty field, line 4, column 8. Please use '-' for null values.
errors in line 4: 
	'sub-amu03	F	28	2019-02-13	amu	AMU - CEMEREM	Siemens	    	NeckMatrix	syngo_MR_B17	Virginie Callot'

incorrect number of columns, line 6
errors in line 6: 
	'sub-amu05	F	39	2019-03-01	amu	AMU - CEMEREM	Siemens	Verio   syngo_MR_B17	Virginie Callot'

It's already added to .gitub/workflows/validator.yml to catch future glitches introduced by the Github web editor or whatever.

This is on top of #87 so please review + merge that first.

@kousu kousu changed the base branch from master to ng/lint-newlines April 18, 2021 15:35
@kousu kousu marked this pull request as ready for review April 18, 2021 20:24
@kousu kousu changed the title script for linting .tsv files Lint .tsv Apr 18, 2021
Copy link
Member

@jcohenadad jcohenadad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't test it but awesome idea

@kousu kousu force-pushed the ng/lint-newlines branch from cf7f8a0 to f05b8b3 Compare April 19, 2021 03:03
Base automatically changed from ng/lint-newlines to master April 19, 2021 14:29
@kousu kousu merged commit 036532b into master Apr 19, 2021
@kousu kousu deleted the ng/lint-tsv branch April 19, 2021 14:41
@jcohenadad jcohenadad added this to the next-release milestone Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants