I’m looking for a logical way to compare a csv list of projects from the user to an array of file paths I generate with glob. It however does not have to happen specifically that way, I just need to take a csv list file of projects and work on them.
CsvScrape = glob.glob('C:\Ryans_Copy_Test\*\*DATA.CSV')
for scrape_items in CsvScrape:
print scrape_items
CsvReader = csv.reader(open(CsvBrowse, 'rb'), dialect=csv.excel)
for reader_items in CsvReader:
print reader_items
it’s not really much yet, but what I had planned was to generate a list of *DATA.CSV files and then match my list of csv projects to them.. I’m running into issues like how would I do a proper comparison (do I strip my glob list of file path info then compare the items, etc) how do I tell the user the project name they entered is not found, etc..
I’m having some trouble explaining what I’m trying to accomplish so if I need to elaborate more on a particular items just let me know.
Thanks.
If glob returns full pathnames:
scrape_items = map(os.path.basename, scrape_items)Your
reader_itemsis probably going to be a list of a list:reader_items = [row[0] for row in reader_items]Use sets to find what’s not there:
not_in_csv = set(reader_items).difference(scrape_items)