Created
March 23, 2016 17:29
-
-
Save buren/0395e629e02c540b5030 to your computer and use it in GitHub Desktop.
and convert languages from Wikimedia to CSV
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
// Extract and convert languages @ below URL to CSV | |
// https://meta.wikimedia.org/wiki/Template:List_of_language_names_ordered_by_code | |
var langCode = []; | |
$('.wikitable tbody tr td:nth-child(1)').each(function(){ | |
langCode.push($(this).text()); | |
}); | |
var enName = []; | |
$('.wikitable tbody tr td:nth-child(2)').each(function(){ | |
enName.push($(this).text()); | |
}); | |
var direction = []; | |
$('.wikitable tbody tr td:nth-child(3)').each(function(){ | |
direction.push($(this).text()); | |
}); | |
var localName = []; | |
$('.wikitable tbody tr td:nth-child(4)').each(function(){ | |
localName.push($(this).text()); | |
}); | |
var matrix = []; | |
for (var i = 0; i < langCode.length; i++) { | |
matrix.push([ | |
langCode[i], | |
enName[i], | |
direction[i], | |
localName[i] | |
]); | |
} | |
var csvContent = ''; | |
var dataString = ''; | |
matrix.forEach(function(infoArray, index){ | |
dataString = infoArray.join(','); | |
csvContent += index < matrix.length ? dataString + "\n" : dataString; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment