Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID DC_trip
- AC A9999
- SY DC,Foggy_bottom,22201,H_St.
- SY DC,Smithsonian,12345,14th_St.
- //
- ID ...
- AC ...
- SY ...
- SY ...
- SY ...
- if lines.find('ID'):
- lines[5:]
- elif lines.find('SY'):
- lines[5:]
- data = []
- # Extract the second row from the input file
- # and store it in data
- with open('input') as in_file:
- csv_reader = csv.reader(in_file, delimiter='t')
- for row in csv_reader:
- data.append(row[1])
- # The first two values in data is the suffix
- # for the rest of your output file
- suffix = ','.join(data[:2])
- # Append the suffix to the rest of the values
- # and write it out to the output file.
- with open('output') as op_file:
- for item in data[2:]:
- op_file.write('{},{}n'.format(suffix, item))
- data = []
- with open('file1') as in_file:
- for line in in_file:
- data.append(line.strip().split())
- data = [a[1] for a in data if a[1]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement