Question: I am getting data from Twitter with Tweepy and using Stream API... Here is my t\_stream.py file:

```
access_token = "my token"
access_token_secret = "my t_secret"
consumer_key = "my key"
consumer_secret = "my c_secret"

class StdOutListener(StreamListener):
    def on_data(self, raw_data):
        data = json.loads(raw_data)
        print(json.dumps(data, ensure_ascii=False))

    def on_error(self, status):
        print (status)

if __name__ == '__main__':

    dinle = StdOutListener()
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    stream = Stream(auth, dinle)

```

I have a file called veri.txt when i use code:

```
    python3 t_stream.py > veri.txt

```

Here is a part of result data: <https://paste.pound-python.org/show/SiUalejehr6T8BEvYOpw/>

From this veri.txt file, i want to get information like:

retweet\_count:

followers\_count:

name:

text:

and i want to store these coloumns as an output csv file...
I tried some codes but it didnt work. So i am asking a python code for reading a text file line by line, getting the information which i mentioned above from the line and storing them as coloumn in data file as a csv file. Can someone help me about this subject? Thank you.

Answer: 
You could use [CRTP](https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern):

```
interface EndoFunctor<X extends Type, T extends EndoFunctor<X, T>> extends Type {
    <Y extends Type> EndoFunctor<Y, ?> fmap(Function<X,Y> map, T fx);    
}

class Id<X extends Type> implements EndoFunctor<X, Id<X>> {
    protected X witness;
    Id(X witness) { this.witness = witness; }

    @Override
    public <Y extends Type> Id<Y> fmap(Function<X, Y> map, Id<X> fx) {
        return new Id<>(map.apply(fx.witness));
    }
}

```
The problem is not that `Id<X>` does not match `EndoFunctor<X>`, but that when you have tried to override `fmap` you have made the parameter types more specific, and consequently the method signature no longer matches the method signature of `fmap` in `EndoFunctor`

This means that `Id<X>` in it's current form does not fully implement the `EndoFunctor<X>` interface. When implementing an interface, it must be possible to interact with your class without needing to know that it's a different interface.

Either follow the advice in the comments about removing this method parameter and using the instance variable, or modify the signature in `Id<X>` to `public <Y extends Type> Id<Y> fmap(Function<X, Y> map, EndoFunctor<X> fx)` to make it compatible with the interface.