-
-
Save shreyasborse/4b894fd71498cfa6f90766f2449a4463 to your computer and use it in GitHub Desktop.
Script for importing zerodha stocks in xlsx to moneycontrol csv if you want to use moneycontrol terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#You'll still have to manually enter dates here, as the xlsx file from zerodha does not show dates(SIP of stocks causes multiple dates) | |
#EDIT: Usage python zerodha_to_moneycontrol.py <FILENAME> | |
import sys | |
from openpyxl import load_workbook | |
wb = load_workbook(sys.argv[1]) | |
ws = wb.active | |
csv_list = [["BSE/NSE/ISIN Code","Buy Date","Buy Quantity","Buy Price",]] | |
curr_row = 15 | |
while True: | |
data = [] | |
data.append(ws.cell(row=curr_row, column=3).value) | |
data.append(' ') | |
data.append(ws.cell(row=curr_row, column=5).value) | |
data.append(ws.cell(row=curr_row, column=10).value) | |
data.append('') | |
csv_list.append(data) | |
curr_row+=1 | |
if ws.cell(row=curr_row, column=3).value == None: | |
break | |
import csv | |
with open("moneycontrol_upload.csv", "wb") as f: | |
writer = csv.writer(f) | |
writer.writerows(csv_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment