Getting Parser Errors and tokenizing data errors while reading "api-master-scrip.csv" in Linux ubuntu

I am not able to read api-scrip-master.csv file using Panda in Python.
Note: I’ve installed ubuntu on my android tablet using termux (terminal) and all python modules have been installed under virtual environment using -venv.

My coding is as follows:

from dhanhq import dhanhq
import pandas as pd

client_id = “client_id”
access_token = “access_token”

dhan = dhanhq(client_id, access_token)

def get_instrument_token():
df = pd.read_csv(‘api-scrip-master.csv’, sep=‘,’, na_values=‘NA’, low_memory=‘FALSE’)
data_dict = {}
for index, row in df.iterrows():
trading_symbol = row[‘SEM_TRADING_SYMBOL’]
exm_exch_id = row[‘SEM_EXM_EXCH_ID’]
if trading_symbol not in data_dict :
data_dict[trading_symbol] = {}
data_dict[trading_symbol][exm_exch_id] = row.to_dict()

return data_dict

token_dict = get_instrument_token()

def get_symbol_name(symbol, expiry, strike, strike_type):
instrument = f’{symbol}-{expiry}-{str(strike)}-{strike_type}’
return instrument

#INPUTS
symbol = ‘NIFTY’
expiry = ‘Mar2024’
strike = ‘22300’
strike_type = ‘PE’
instrument = get_symbol_name(symbol, expiry, strike, strike_type)

print(token_dict[instrument][‘NSE’][‘SEM_LOT_UNITS’])
print(token_dict[instrument][‘NSE’][‘SEM_SMST_SECURITY_ID’])

token_dict = get_instrument_token()

Hello @k4u5h47

You can use this to skip those lines with more than intended data columns.

data = pd.read_csv('file1.csv', on_bad_lines='skip')

Meanwhile, will check this row in the Security ID List.

I’ve already tried this before… but it results in getting wrong codes:
It prompted NSE “HDFCBANK” security ID as “20753” instead “1333” which is for NSE “HDFCBANK7.71%2033SR1” bond.


@k4u5h47

The code snippet shared above will only skip rows. However, the issue pointed out by you can simply be resolved by keeping a check on SERIES column to only take EQ or ES tags.