Pandas Dataframe (read file stored in database)

Is the issue retrieving the file from the database or that the Media Object you get from it doesn’t behave like the TempFile? Or is it an issue with querying based on the file_object?

Update: I made some modifications to your function and used the url property instead of a TempFile.
(My DB Table only has a file_object file, and you can’t query on Media Columns)

@anvil.server.callable
def read_csv():
  file = app_tables.table_1.search()
  file = [f['file_object'] for f in file if f['file_object'].content_type == 'text/plain'][0]
  print(file.content_type)
  if file.content_type == 'text/csv':
    df = pd.read_csv(file.url)
  elif file.content_type == 'text/plain':
    df = pd.read_table(file.url)
  else:
    df = pd.read_excel(file.url)
  for d in df.to_dict(orient="records"):
    # d is now a dict of {columnname -> value} for this row
    # We use Python's **kwargs syntax to pass the whole dict as
    # keyword arguments
    # app_tables.data.add_row(**d) This Outside
    print(d)
    pass
  dft = pd.DataFrame.from_dict(df) #New line for read the file
  print(dft)