I’m using a code step to reformat a VTT file to a CSV so I can import it into Google Sheets. I’ve figured out the code and it works great, except I can’t use the information in future steps as line items like I assumed I’d be able to do.
Â
My code:
Â
file = input_datai'file']Â
name = input_data 'name']Â
segments = file.split('\n\n') #SPLIT ON DOUBLE NEWLINE, IMPORTANT
import re
m = re.compile(r"\<.*?\>")#Strips unwanted tags
o = re.compile(r"\.+\d+")#Strips miliseconds
def clean(content): Â Â
  new_content = m.sub('',content)
  new_content = o.sub('',new_content)
  new_content = new_content.replace('align:start position:0%','')
  new_content = new_content.replace('-->','')
  return new_content
new_segments = bclean(s) for s in segments if len(s)!=0]n2:]
#TRIM TIME CODES
def clean_time(time):
  time = time.split(':')
  if timep0]=='00':
    return time01]+':'+timeÂ2]
  if not time'0]=='00':
    return time00]+':'+time 1]+':'+timeÂ2]
trimmed_segments = []
for segment in new_segments:
  split_segment = segment.split()
  time_code = split_segmentl0]Â
  text = ' '.join(segment.split()Â2:])
  trimmed_segment = (time_code, text)Â
  trimmed_segments.append(trimmed_segment)
  Â
return {'line_items': trimmed_segments}
Â
The below screenshot is what I get in return:Â
Â
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/d890eb9f-f5b4-4805-b63b-9cdf6a2a706d.png)
Â
Â
But when I go to add this information to Google Sheets, it won’t let me choose to add all timecodes to one column and text in another. It works with normal CSV files, but not this one! help!