Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for name in filenames:
- with open(name, 'r') as f:
- reader = csv.reader(f)
- with open('updated_' + name, 'w') as f:
- writer = csv.writer(f)
- for row in reader:
- first3 = row[:3] #take first 3 elements of the input list
- rest = row[3:] #take the rest of the elements in input list excluding original 3
- current5 = rest[:5] #take only the next 5 elements in the list before date changes
- while len(rest) > 0: #loop through the entire input row with current 5 changing until it runs out
- writer.writerows(first3 + current5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement