original_docstring: Uses pandas to read historical CSV file.
      Parses data then imports into sqlite.
      
docstring: Uses pandas to read historical CSV file.
  Parses data then imports into sqlite.
docstring_tokens: Uses pandas to read historical CSV file . Parses data then imports into sqlite .
code: async def import_hist_data(csv_path):
      """Uses pandas to read historical CSV file.
      Parses data then imports into sqlite.
      """
  
      df = pandas.read_csv(csv_path)
      df_list = df.values
      currencies = [
          "USD",
          "JPY",
          "BGN",
          "CYP",
          "CZK",
          "DKK",
          "EEK",
          "GBP",
          "HUF",
          "LTL",
          "LVL",
          "MTL",
          "PLN",
          "ROL",
          "RON",
          "SEK",
          "SIT",
          "SKK",
          "CHF",
          "ISK",
          "NOK",
          "HRK",
          "RUB",
          "TRL",
          "TRY",
          "AUD",
          "BRL",
          "CAD",
          "CNY",
          "HKD",
          "IDR",
          "ILS",
          "INR",
          "KRW",
          "MXN",
          "MYR",
          "NZD",
          "PHP",
          "SGD",
          "THB",
          "ZAR",
      ]
      for row in df_list:
          for k, v in enumerate(row):
              if k == 0:
                  the_date = datetime.strptime(v, "%Y-%m-%d")
              elif k == 41:
                  break
              else:
                  print(f"{currencies[k]},{the_date},{v}")
                  currency = Currency(
                      currency=currencies[k], date=the_date, rate=v
                  )
                  try:
                      session.add(currency)
                      session.commit()
                  except exc.IntegrityError:
                      session.rollback()
                      print("Entry exists")
                  except exc.PendingRollbackError:
                      session.rollback()
                      session.flush()
                  finally:
                      session.close
code_tokens: async def import_hist_data ( csv_path ) : df = pandas . read_csv ( csv_path ) df_list = df . values currencies = [ "USD" , "JPY" , "BGN" , "CYP" , "CZK" , "DKK" , "EEK" , "GBP" , "HUF" , "LTL" , "LVL" , "MTL" , "PLN" , "ROL" , "RON" , "SEK" , "SIT" , "SKK" , "CHF" , "ISK" , "NOK" , "HRK" , "RUB" , "TRL" , "TRY" , "AUD" , "BRL" , "CAD" , "CNY" , "HKD" , "IDR" , "ILS" , "INR" , "KRW" , "MXN" , "MYR" , "NZD" , "PHP" , "SGD" , "THB" , "ZAR" , ] for row in df_list : for k , v in enumerate ( row ) : if k == 0 : the_date = datetime . strptime ( v , "%Y-%m-%d" ) elif k == 41 : break else : print ( f"{currencies[k]},{the_date},{v}" ) currency = Currency ( currency = currencies [ k ] , date = the_date , rate = v ) try : session . add ( currency ) session . commit ( ) except exc . IntegrityError : session . rollback ( ) print ( "Entry exists" ) except exc . PendingRollbackError : session . rollback ( ) session . flush ( ) finally : session . close
short_docstring: Uses pandas to read historical CSV file.
short_docstring_tokens: Uses pandas to read historical CSV file .
comment: """Uses pandas to read historical CSV file.
      Parses data then imports into sqlite.
      """