Spent the long weekend fiddling with R and Python mainly to pull the data - and then cleaning and reorganising.
Among others, I wrote a python script to reorganise the table containing seismological record from seismonepal.gov.np website.
=ImportHTML() is a handy function to fetch the data from a table or list. It time saver trick in Google Spreadsheet when the source data is available in a tabular or list form.
=ImportHTML("http://seismonepal.gov.np/index.php", "table", 1)
Next, a python script converts data in English into Nepal
#List of character/word to be replaced
replaceDict = {
'1':'१' ,
'2':'२' ,
'3':'३' ,
'Local Time' : 'LocalTime',
'Magnitude(ML)' : 'Magnitude',
'Achham' : 'अछाम' ,
'Arghakhanchi' : 'अर्घाखाँची' ,
'Baglung' : 'बाग्लुङ'
}
#Function to replace word
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
#Iteration
with open('earthquake.csv', 'rb') as csvfile:
earthquake = csv.reader(csvfile, delimiter=',')
for row in range(record2read):
row = [word.replace('*','') for word in earthquake.next()]
row = ' '.join(row).encode('utf-8')
row = replace_all(row, replaceDict)
And writing the result into JSON format with Nepali data.
{
"earthquake": [
{
"MM": "५",
"DD": "१७",
"Longitude": "८५.८७",
"Epicentre": "रामेछाप",
"Magnitude": "४.६",
"YYYY": "२०१५",
"Remarks": "NSC",
"Date": "१७/०५/२०१५",
"Latitude": "२७.४८",
"LocalTime": "११:३०"
},
{
"MM": "५",
"DD": "१७",
"Longitude": "८६.०६",
"Epicentre": "दोलखा",
"Magnitude": "४.४",
"YYYY": "२०१५",
"Remarks": "NSC",
"Date": "१७/०५/२०१५",
"Latitude": "२७.७३",
"LocalTime": "०५:००"
},
{
"MM": "५",
"DD": "१६",
"Longitude": "८६.१४",
"Epicentre": "दोलखा",
"Magnitude": "४.३",
"YYYY": "२०१५",
"Remarks": "NSC",
"Date": "१६/०५/२०१५",
"Latitude": "२७.६४",
"LocalTime": "२०:४४"
}]}
Finally - widget based on above JSON file. HimalKhabar has embedded it in its website.
भूकम्पको लाइभ अपडेट http://t.co/yfbJgjRYxA मा ।
— Himal Khabar (@Himal_Khabar) May 18, 2015