add csv formatter
This commit is contained in:
parent
ec33150bd4
commit
146ab01de4
|
@ -4,6 +4,7 @@ on:
|
|||
push:
|
||||
paths:
|
||||
- 'blogs-original.csv'
|
||||
- 'formatter.py'
|
||||
- 'opml_generator.py'
|
||||
- 'script.js'
|
||||
- '.github/workflows/updateInfo.yml'
|
||||
|
@ -23,6 +24,9 @@ jobs:
|
|||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: formatter
|
||||
run: |
|
||||
python formatter.py
|
||||
- name: update readme
|
||||
run: |
|
||||
npm install
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
with open('blogs-original.csv', 'r') as f:
|
||||
file_content = f.read()
|
||||
|
||||
lines = file_content.split('\n')
|
||||
|
||||
content = lines[0] + '\n'
|
||||
|
||||
for line in lines[1:]:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
parts = line.split(',')
|
||||
if len(parts) != 4:
|
||||
continue
|
||||
parts = [part.strip() for part in parts]
|
||||
|
||||
if parts[3]:
|
||||
parts[3] = parts[3].strip().replace(';', ';')
|
||||
tags = parts[3].split(';')
|
||||
tags = [tag.strip() for tag in tags]
|
||||
parts[3] = ';'.join([tag for tag in tags if tag])
|
||||
content += ', '.join(parts) + '\n'
|
||||
|
||||
with open('blogs-original.csv', 'w') as f:
|
||||
f.write(content)
|
Loading…
Reference in New Issue