Intraday Margin File Downloading

devshoe
https://docs.google.com/spreadsheets/d/1fLTsNpFJPK349RTjs0GRSXJZD-5soCUkZt9eSMTJ2m4/edit#gid=288818195

This is your daily margin file, I want to download it programatically when I download the daily instrument dump. No clue how to proceed with downloading from google sheets programatically. Please help
  • Imran
    Hi @devshoe
    To read the spreadsheet from the given URL, you can follow the given steps.
    1. Every Google spreadsheet contains a sheet ID.
    ex - this sheet has ID = 1fLTsNpFJPK349RTjs0GRSXJZD-5soCUkZt9eSMTJ2m4
    2. copy and split the URL till that sheet ID and then add /export?format=csv in the end.
    3. Then use the below code for getting sheet data into a dataframe.

    import pandas as pd
    df = pd.read_csv(f"https://docs.google.com/spreadsheets/d/1fLTsNpFJPK349RTjs0GRSXJZD-5soCUkZt9eSMTJ2m4/export?format=csv")
    print(df)
  • devshoe
    Thanks so much!
  • devshoe
    Hello, how do I reference the other sheet. Theres two, one for EQ and one for FO. I want CSV for the second sheet. Thanks
  • Imran
    @devshoe
    Instead of CSV, you may use excel to download individual sheets.
    ex -
    import pandas as pd
    df_EQ = pd.read_excel(f"https://docs.google.com/spreadsheets/d/1fLTsNpFJPK349RTjs0GRSXJZD-5soCUkZt9eSMTJ2m4/export?format=xlsx", sheet_name = 0)
    df_FNO = pd.read_excel(f"https://docs.google.com/spreadsheets/d/1fLTsNpFJPK349RTjs0GRSXJZD-5soCUkZt9eSMTJ2m4/export?format=xlsx", sheet_name = 1)
  • devshoe
    I’m actually using Go so pandas doesn’t help. Found a excel lib for it. Thanks a lot!
Sign In or Register to comment.