Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. A00
  2. A10
  3. A21
  4.  
  5. ”09321609”,”15274”, etc.
  6.  
  7. 00I
  8. 0109321609
  9. 0215274
  10. 032
  11. 0419685
  12. 05
  13. 062
  14. 072
  15. 081
  16. 09
  17. 111
  18. 121
  19. 15
  20. 161
  21. 17
  22. 1814740
  23. 1920120401
  24. 2020120401
  25. 2120120401
  26. 22
  27. 230
  28. 240
  29. 251
  30. 26BLAHBLAH 1000MG
  31. 27
  32. 281
  33. 29
  34. 30
  35. 31BLAHBLAH 1000 mg Filmtablets Hursutacinzki
  36. 32
  37. 3336
  38. 341
  39. 350
  40. 361
  41. 371
  42. 401
  43. 410
  44. 420
  45. 43
  46. 445774
  47. 45FTA
  48. 46
  49. 47AN03AX14
  50. 48BLAHBLAH00000000000000000000010
  51. 491
  52. 501
  53. 512
  54. 522
  55. 5317
  56. 542
  57. 552
  58. 561
  59. 572
  60. 581
  61. 591
  62. 60
  63. 61
  64. 62
  65. 631
  66. 641
  67. 65
  68. 66
  69. 67
  70. 681
  71. 69
  72. 721
  73. 74884
  74. 761
  75. 771
  76. 780
  77. 790
  78. 801
  79. 811
  80. 831
  81. 851474
  82. 86
  83. 871
  84. 880
  85. 891
  86. 901
  87. 911
  88. 922
  89. 930
  90. 941
  91. 951
  92. 961
  93. 97
  94. 98
  95. 990
  96. A00
  97. A10
  98. A21
  99.  
  100. from itertools import izip
  101. import csv
  102.  
  103. with open('data.txt') as inf, open('data.csv','wb') as outf:
  104. lines = (line[2:].rstrip() for line in inf)
  105. rows = (data[1:89] for data in izip(*([lines]*92)))
  106. csv.writer(outf).writerows(rows)
  107.  
  108. import csv
  109. fo = csv.writer(open('out.csv','wb'))
  110. with open('eg.txt', 'r') as f:
  111. for line in f:
  112. assert line[:3] == '00I'
  113. buf = []
  114. for i in range(88):
  115. line = f.next()
  116. buf.append(line.strip()[2:])
  117.  
  118. line = f.next()
  119. assert line[:3] == 'A00'
  120. line = f.next()
  121. assert line[:3] == 'A10'
  122. line = f.next()
  123. assert line[:3] == 'A21'
  124. fo.writerow(buf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement