Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # this script fixes output problems created by Zotero
  3.  
  4. original_string = r'''@article{lewitt_serial_1967,
  5.     title = {Serial Project \#1, 1966},
  6.     url = {http://www.ubu.com/aspen/aspen5and6/serialProject.html},
  7.     pages = {n.p.},
  8.     number = {5},'''
  9.    
  10. replacement_string = r'''@article{lewitt_serial_1967,
  11.     title = {Serial Project \#1, 1966},
  12.     url = {http://www.ubu.com/aspen/aspen5and6/serialProject.html},
  13.     pages = {n.p.},
  14.     number = {5+6},'''
  15.  
  16. input_file_as_single_string = r''
  17. with open('./bibliography.bib') as input_file:
  18.     for line in input_file:
  19.         input_file_as_single_string += line
  20.  
  21. modified_file_as_single_string = input_file_as_single_string.replace(
  22.     original_string,
  23.     replacement_string,
  24. )
  25.    
  26. with open('./bibliography.bib', 'w') as output_file:
  27.     output_file.write(modified_file_as_single_string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement