Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 8,
  6. "metadata": {
  7. "collapsed": true
  8. },
  9. "outputs": [],
  10. "source": [
  11. "import os, subprocess, glob, fileinput"
  12. ]
  13. },
  14. {
  15. "cell_type": "markdown",
  16. "metadata": {},
  17. "source": [
  18. "Edit text files"
  19. ]
  20. },
  21. {
  22. "cell_type": "code",
  23. "execution_count": 10,
  24. "metadata": {
  25. "collapsed": true
  26. },
  27. "outputs": [],
  28. "source": [
  29. "file_list = glob.glob('2016_9_Dean/test_file*')\n",
  30. "for line in fileinput.input(file_list, inplace = 1): \n",
  31. " print line.replace(\"original_string\", \"replacement_string\")"
  32. ]
  33. },
  34. {
  35. "cell_type": "markdown",
  36. "metadata": {},
  37. "source": [
  38. "Re run files"
  39. ]
  40. },
  41. {
  42. "cell_type": "code",
  43. "execution_count": null,
  44. "metadata": {
  45. "collapsed": true
  46. },
  47. "outputs": [],
  48. "source": [
  49. "for file_name in glob.glob('ici.LBCO*'):\n",
  50. " subprocess.call('./icscan3 {}'.format(file_name),shell=True)"
  51. ]
  52. }
  53. ],
  54. "metadata": {
  55. "kernelspec": {
  56. "display_name": "Python 2",
  57. "language": "python",
  58. "name": "python2"
  59. },
  60. "language_info": {
  61. "codemirror_mode": {
  62. "name": "ipython",
  63. "version": 2
  64. },
  65. "file_extension": ".py",
  66. "mimetype": "text/x-python",
  67. "name": "python",
  68. "nbconvert_exporter": "python",
  69. "pygments_lexer": "ipython2",
  70. "version": "2.7.11"
  71. }
  72. },
  73. "nbformat": 4,
  74. "nbformat_minor": 0
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement