Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open("file1.txt") as input_file:
- with open("file2.txt") as output_file:
- for line in input_file:
- if line.startswith(">"):
- name = line.strip()
- # do something interesting with the name
- output_file.write(name+"\n")
- else:
- data = line.strip().split(";")
- # do something interesting with the data
- output_file.write(data+"\n")
- with open("file2.txt") as input_file:
- with open("file3.txt") as output_file:
- for line in input_file:
- if line.startswith(">"):
- name = line.strip()
- # do something interesting with the name
- output_file.write(name+"\n")
- else:
- data = line.strip().split(";")
- # do something interesting with the data
- output_file.write(data+"\n")
- ########################################################
- first_data = []
- with open("file1.txt") as input_file:
- for line in input_file:
- if line.startswith(">"):
- name = line.strip()
- # do something interesting with the name
- else:
- data = line.strip().split(";")
- # do something interesting with the data
- row = (name, data) # tuple!
- first_data.append(row)
- second_data = []
- for name, data in first_data:
- new_data = # do something to data to make new_data
- row = (name, new_data)
- second_data.append(row)
- with open("file3.txt") as output_file:
- for name, data in second_data:
- # do something interesting with the name and data
- output_file.write(name+"\n")
- output_file.write(data+"\n)
Advertisement
Add Comment
Please, Sign In to add comment