insert URLs in kunamed.bst - bibtex

I am using LyX and would like to add URLs to my #misc entries in my bibtex bibliography. I am using the kunamed.bst style for my bibliography. My bibtex entries looks like this
#misc{RFA2011,
author = {RFA},
booktitle = {Statistics},
title = {{Renewable Fuels Association}},
url = {http://www.ethanolrfa.org/pages/statistics},
urldate = {Jan 13th 2014},
year = {2014}
}
I have tried to change the FUNCTION {misc} in the kunamed.bst file like from this:
FUNCTION {misc}
{ output.bibitem
format.authors output
author format.key output
output.year.check
format.title output
format.date output
new.block
howpublished output
new.block
note output
fin.entry
}
to this
FUNCTION {misc}
{ output.bibitem
format.authors output
author format.key output
output.year.check
format.title output
format.date output
format.url output % <------
new.block
howpublished output
new.block
note output
fin.entry
}
No change is happening in my bibliography. Any ideas how to fix this?

I solved the problem myself by changing the way the url is written in the bibtex entry
#misc{RFA2011,
author = {RFA},
booktitle = {Statistics},
title = {{Renewable Fuels Association}},
howpublished = "\url{http://www.ethanolrfa.org/pages/statistics}", % <---
year = {2014},
note = "[Accessed online: 13-Jan-2014]"

Related

Saving json array output to txt file and getting errors when attempting to parse

I am unable to parse a JSON array from a text file due to errors and my limited knowledge of JSON.
The file looks something like this [{"random":"fdjsf","random56":128,"name":"dsfjsd", "rid":1243,"rand":674,"name":"dsfjsd","random43":722, "rid":126},{"random":"fdfgfgjsf","random506":120,"name":"dsfjcvcsd", "rid":12403,"rando":670,"name":"dsfooojsd","random4003":720, "rid":120}] It has more than one object({}) in the entire array however I did not want to include all 600. The layout shown above is basically how all of them look.
r = s.get(getAPI, headers=header, verify=False)
f = open('text.txt', 'w+')
f.write(r.text)
f.close
output_file = open ('text.txt', 'r')
json_array = json.load(output_file)
json_list = []
for item in json_array:
name = "name"
rid = "rid"
json_items = {name:None, rid:None}
json_items = [name] = item[name]
json_items = [rid] = item[rid]
json_list.append(json_items)
print(json_list)
I would like to loop through an array and find any time it says "name":... eventually followed by "rid":... and store those in a dictionary as key value pairs.
Errors:
ValueError: too many values to unpack (expected 1)
There is a syntax error when you assign values to json_items, change it to:
json_items[name] = item[name]
json_items[rid] = item[rid]

How do I get matches from a text file and output them in an array?

I'm using a text file with lines of movies. If a user inputs Oz, I want to output all the movies in the file that have the word Oz in it.
This is what I have so far.
puts "Enter the keyword you want to search for: "
keyword = gets
movies_file = File.new("movies.txt", "r")
movies = movies_file.read
movies_list = movies.split(" ")
match_list = []
movies_list.each do |w|
matchObj = w.match(keyword)
if matchObj then
matchlist.push(matchObj.captures[0])
end
end
match_list.each do |title|
puts title
end
Presuming you've got the file organized like this:
Wizard of Oz
Battlefield Earth
Twilight
Ozymandias
Then you can read it in this way:
lines = File.readlines('movies.txt').map(&:chomp)
Then to find matching lines:
matches = lines.grep(phrase)
There's no need for all the each stuff. Also the then on an if is almost never put in there, it's just useless decoration.

Find string in log files and return extra characters

How can I get Python to loop through a directory and find a specific string in each file located within that directory, then output a summary of what it found?
I want to search the long files for the following string:
FIRMWARE_VERSION = "2.15"
Only, the firmware version can be different in each file. So I want the log file to report back with whatever version it finds.
import glob
import os
print("The following list contains the firmware version of each server.\n")
os.chdir( "LOGS\\" )
for file in glob.glob('*.log'):
with open(file) as f:
contents = f.read()
if 'FIRMWARE_VERSION = "' in contents:
print (file + " = ???)
I was thinking I could use something like the following to return the extra characters but it's not working.
file[:+5]
I want the output to look something like this:
server1.web.com = FIRMWARE_VERSION = "2.16"
server2.web.com = FIRMWARE_VERSION = "3.01"
server3.web.com = FIRMWARE_VERSION = "1.26"
server4.web.com = FIRMWARE_VERSION = "4.1"
server5.web.com = FIRMWARE_VERSION = "3.50"
Any suggestions on how I can do this?
You can use regex for grub the text :
import re
for file in glob.glob('*.log'):
with open(file) as f:
contents = f.read()
if 'FIRMWARE_VERSION = "' in contents:
print (file + '='+ re.search(r'FIRMWARE_VERSION ="([\d.]+)"',contents).group(1))
In this case re.search will do the job! with searching the file content based on the following pattern :
r'FIRMWARE_VERSION ="([\d.]+)"'
that find a float number between two double quote!also you can use the following that match anything right after FIRMWARE_VERSIONbetween two double quote.
r'FIRMWARE_VERSION =(".*")'

Print News Headlines with Python/JSON

I'm having difficulty properly parsing an array. I realize this is a newb error, so please forgive me.
Example:
import urllib2
import json
import sys
print "Good Morning, Rusty"
i = 0
print "From USA Today: Top Headlines"
f = urllib2.urlopen('http://api.usatoday.com/open/articles/topnews?encoding=json&api_key=98j............v5a93qs')
json_string = f.read()
parsed_json = json.loads(json_string)
for i in parsed_json[0]['stories']['title']:
print json.dump(i)
f.close()
There's one major section called stories, and under it multiple occurrences of description, title, link, pubDate and several other fields.
I simply want to print the dozen or so titles presented by that JSON.
Well, I did more learning and research, and at least got code that would print the top 5 headlines:
Here's what I solved this with:
json_string = f.read()
parsed_json = json.loads(json_string)
for i in range(6):
title = parsed_json['stories'][i]['title']
link = parsed_json['stories'][i]['link']
print title
print link
print "-----------------------------------"

Can't edit root_blip of fetched wavelet

When i edit root_blip of wavelet everything works fine, but if i fetch the wavelet nothing happens neither in googleWave nor logs (no errors occured), although "wave_list.reply(text)" works. I have made myRobot.setup_oauth()
def OnWaveletSelfAdded(event, wavelet):
text = "123"
wave_list = myRobot.fetch_wavelet(wave_id="googlewave.com!w+O5yFQIteC", wavelet_id="googlewave.com!conv+root")
wave_list.submit_with(wavelet)
root_blip = wave_list.root_blip
root_blip.all().delete()
root_blip.append("WaveList\n" + text)
logging.info("root_blip.wave_id: %s" % root_blip.wave_id)
What am I doing wrong? I've tried myRobot.submit(wave_list) - also no results
wave_list = myRobot.fetch_wavelet(wave_id = wave_id, wavelet_id="googlewave.com!conv+root")
root_blip = wave_list.root_blip
root_blip.all().delete()
root_blip.append("WaveList:\n")
myRobot.submit(wave_list)
solved...

Resources