Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Cannot import own csv file

    General Discussion
    datetime csv python 3
    1
    2
    73
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LucPC last edited by

      I am having trouble importing my own CSV file. This is the code I use:

          data = bt.feeds.GenericCSVData(
              dataname='df.csv',
      
              fromdate=datetime(2018, 2, 2),
              todate=datetime(2021, 1, 1),
      
              dtformat=('%Y-%m-%d %H:%M:%S'),
      
              datetime=0,
              open=1,
              close=2,
              high=3,
              low=4,
              volume=5,
              openinterest=-1)
      

      And this is the df.csv file I use:
      88ce006c-09c3-4f44-acdc-0d2fb7085589-image.png

      I get the following error:

      ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S'
      

      But I do not understand why I get this error, since the format is correct? Hopefully someone sees what I am doing wrong here (:

      L 1 Reply Last reply Reply Quote 0
      • L
        LucPC @LucPC last edited by

        @lucpc Seems like there are NA values in the Date column, I'm fixing that now

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors