SHARE
TWEET

Untitled

a guest May 19th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. f = open('myfile.csv')
  2. out = []
  3. rows_to_delete = {64, 108, 148, 247, 311, 314, 342, 343, 344, 345, 346, 359, 360, 361, 376, 377, 379, 381, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 416, 417, 418, 419, 420, 421, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 483, 484, 488, 489, 490, 492, 493, 495, 504, 514, 526, 553, 554, 555, 556, 557, 558}
  4.  
  5. for i, line in enumerate(f):
  6.         if i - 1 not in rows_to_delete:
  7.                 out.append(line)
  8.  
  9. newfile = open('newfile.csv', 'w')
  10. for line in out:
  11.         newfile.write(line)
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top