For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

How to ignore 2 headers in a GenericCSV



  • Screenshot_2.png
    I've got headers on True but it seems to only ignore the first header and read 'Date' as an actual data



  • I didn't try it myself, but probably the following may work:

    class MyGenericCSVData(bt.GenericCSVData):
        def start(self):
            super(MyGenericCSVData, self).start()
            if self.p.headers:
                self.f.readline()  # skip the second header (the first one was skipped in GenericCSVData start method)
    
    class MyGenericCSV(bt.GenericCSV):
        DataCls = MyGenericCSVData
    

    Thanks
    Vlad


  • administrators

    The subclass from @vladisld does for sure work.

    You may also read the file with pandas.read_csv, skip what you need and pass it to Cerebro as a PandasData feed.


Log in to reply
 

});