dictionary inside 2 loops to save to a single file
Question: I intend to write in a single file (for each function), but inside the "loop
in the loop" I got trapped.

It's working except the storage/ save part, now writes a file for each inner
loop: ## def t2(): ##

But I wish to improve and also work with the current 'dic' or 'list' in the
next pool/ funtion t'x'(): and so on, to avoid have to open the csv in the
jorney.

what's the lesson over here? :p It's my 1st data scrape, I'm new to python!

    
    
    import    
    
    def t0(url): # url
    soup ('http://www.foo.net')
    return soup
    
    def t1(): # 1st_pool
        soup = t0()
        dic = {}
        with open('dic.csv', 'w') as f:
            for x in range(15):
                try:
                    collect
                    dic[name] = link
                    f.write('{0};{1}\n'.format(name, link))
                except:
                    pass
    
        return dic
    
    def t2(): # 2nd_pool
        dic = t1()
        dic2 = {}
        for k,v in dic.items():
            time.sleep(3)
            with open(k+'_dic.csv', 'w') as f:
                for x in range(13):
                    try:
                        collect
                        dic2[name] = link
                        f.write('{0};{1}\n'.format(name, link))
                    except:
                        pass
    
        return ###############
    
    def t3(): ... # 3rd_pool
    def t4(): ... # 4th_pool
    def t5(): ... # 5th_pool
    def t6(): ... # full_path /to /details
    


Answer: As I mention early, the "problem" resides only in the fact that was creating a
individual *.csv (to not overwrite the previous loop) for each loop, so now I
figured out how to create a single file.csv for each function:

    
    
    def t2(): # 2nd_pool
        dic = t1()
        dic2 = {}
        for k,v in dic.items():
            time.sleep(3)
            ##
            for x in range(13):
                try:
                    collect
                    dic2[name] = link
                    ##
                except:
                    pass
        ##
        with open('dic2.csv', 'w') as f:
            for n,j in dic2.items():
                f.write('{0};{1}\n'.format(n, j))
        ##
        return dic2
    

I simply moved the "*.csv operation" ( ## represent the chages) to the end of
the function, outside of the "double loop", and the dictionary it's also
available in the next function # t3():# and so on.

I was trying to achieve that without write the extra loop, so if someone can
provide a better alternative, I would like to learn!

