Skip to content

Instantly share code, notes, and snippets.

@rakhmaevao
Created August 12, 2021 06:39
Show Gist options
  • Save rakhmaevao/dc122d3f301d4f49f52d3f0179460630 to your computer and use it in GitHub Desktop.
Save rakhmaevao/dc122d3f301d4f49f52d3f0179460630 to your computer and use it in GitHub Desktop.
Данный скрипт конвертирует csv таблицу в таблицу для формуа ВГД
"""Данный скрипт конвертирует csv таблицу в таблицу для формуа ВГД"""
import pandas as pd
from numpy import NaN
df = pd.read_csv('input.csv', delimiter=',')
f = open('output.txt', 'w')
f.write('[table]\n')
f.write(f' [tr]')
for column_name in df.columns.values.tolist():
f.write(f'[td][b]{column_name}[/b][/td]')
f.write(' [/tr]\n')
for index, row in df.iterrows():
f.write(' [tr]')
for index, cell_value in row.iteritems():
value = cell_value if str(cell_value) != 'nan' else ''
f.write(f'[td]{value}[/td]')
f.write(' [/tr]\n')
f.write('[/table]\n')
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment