INNER CODE UNIT · Python
process_csv
DrewThomasson/VoxNovel · 2GPU_Audio_generation.py:80
def process_csv(df, split_string):
new_rows = []
for _, row in df.iterrows():
text = row['Text']
if isinstance(text, str) and split_string in text:
new_rows.extend(split_text(text, split_string, row))
else:
new_rows.append(row)
return pd.DataFrame(new_rows)
# Read the CSV file
df = pd.read_csv(file_path)
# Process the DataFrame
new_df = process_csv(df, split_string)
# Write the modified DataFrame back to the CSV file
new_df.to_csv(file_path, index=False)