Files
multi-sound-player/process
T

27 lines
707 B
Python
Raw Normal View History

2023-07-09 03:14:12 -07:00
#!/usr/bin/env python
import sys
import csv
# Strip whitespace left and right of a string
def strip(s: str):
return s.rstrip().lstrip()
def main():
filepaths = sys.argv[1:]
2023-07-09 03:23:22 -07:00
# print(f'{filepaths=}')
2023-07-09 03:14:12 -07:00
delim=','
quotechar='"'
for file in filepaths:
with open(file, newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=delim, quotechar=quotechar, skipinitialspace=True)
next(reader) # Skip the first row
for row in reader:
2023-07-09 03:15:16 -07:00
# Strip any whitespace in the csv file
2023-07-09 03:14:12 -07:00
stripped = map(strip, row)
[keyword, text, sound] = stripped
2023-07-09 03:35:13 -07:00
print(f'{keyword}|{text}|{sound}')
2023-07-09 03:14:12 -07:00
main()