-1

I have this value taken from SQL "[4,8,12,16]". Python treats it as string but when hardcoded to rrule it seems to work if today in rrule(DAILY, dtstart = start_date, byhour=[4,8,12,16], byminute=row.minute, bysecond=0):

How to convert the string so that rrule function will accept it? Thanks for the help.

Rav
  • 1,327
  • 3
  • 18
  • 32
  • Can you share how you are obtaining this value from the database? It may be possible to extract it in the format that you want. We would probably need the query and the relevant parts of the create table statement. – snakecharmerb Jun 13 '21 at 10:51
  • The column is in nvarchar. I just used a basic SELECT hours FROM table @snakecharmerb – Rav Jun 13 '21 at 10:58
  • Does this answer your question? [Python - Convert string to list with same structure](https://stackoverflow.com/questions/48979445/python-convert-string-to-list-with-same-structure) – rajah9 Jun 13 '21 at 11:00
  • Hmmm, I think you'll have do the transform on the python side then. – snakecharmerb Jun 13 '21 at 11:19

1 Answers1

1

you can convert string to list through json

import json
print(json.loads("[4,8,12,16]"))
gaurav
  • 1,281
  • 1
  • 13
  • 25