Hi

I know how to import a individual file

def cvt(s,default=-1):
    try:
        return float(s)
    except ValueError:
        return default

import csv
with open("Dealer1.txt", "rb") as csvfile:
    reader = csv.reader(csvfile, delimiter="\t")
    data = list(reader)

I have a folder that contains 50+ files, using Glob, I created the following code

import os
import glob

os.chdir('c:/Performance')
files = glob.glob('*.txt')
print files

Now is there a way that instead of me importing individual files I can actual import all 50 files data at the same time, all 50 have the same layout can I import all the data from the txt files in one go

Jezza

csvfile = fileinput.input(glob.glob('*.txt')) may work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.