0

I am trying to import multiple CSV files into dictionary and then can access and send each cvs file to another function. I have this code:

def readfile():

    path = '~/CSVFiles' 
    df = pd.DataFrame()
    csvFiles = glob.glob(path + "/*.csv")
    listoflist={}
    for files in csvFiles:
        csvlist=pd.read_csv(files)
        listoflist[files]=csvlist

    return listoflist

data=readfile()   

for i in data
    Bining_data(data[i])  # Bining is another function 

##########

But, when I run this code I get error.

Remy J
  • 709
  • 1
  • 7
  • 18
RZA KHK
  • 35
  • 4
  • 2
    What error are you getting? What are you planning on doing with the csv files? If you're not going to do some calculations it will be better not to use pandas. – Gabriel May 13 '17 at 14:47
  • Also, `listoflist` is not a list and does not contain a list. It's a dictionary that you want to use to hold Data frames – roganjosh May 13 '17 at 15:00
  • Yes, I think found the problem. I was confuse between list and dictionary. So I used "key" to reach and access to the CSV file in dictionary. with following code: for key in Csv_Dics.keys(): data_binded=CategorizeData(Csv_Dics[key]) – RZA KHK May 13 '17 at 16:39
  • You may want to read [ask] and [mcve]. – boardrider May 14 '17 at 08:28

0 Answers0