python - Referencing a csv within a zip file by its absolute path -


i have bunch of zip files within directory, , each zip file contains few csv's. i'm curious if it's possible files within each zip file, , add absolute paths list can referenced directly later?

what have far below:

# d directory folders containing zip files dirpath, _, filenames in os.walk(d):     csv_list = []      # works since zip files files , not folders     f in filenames:         fp = os.path.abspath(os.path.join(dirpath, f))          if zipfile.is_zipfile(fp):              # need unzip , add contents             names_to_add = zipfile.zipfile(fp).namelist()             paths_to_add = [os.path.join(fp, i) in names_to_add]              # how absolute paths csv's?             csv_list.extend(paths_to_add)          else:              # csv file             csv_list.append(fp)  # want contain absolute paths directly csv's print csv_list 

in other words, want treat zip files folders can ignore them , reference csv's within them directly. possible? or need extract first? if so, easy script run extract files folders same name? thanks.

edit: when trying open of csv files in csv_list, getting error:

[errno 2] no such file or directory: '\\\\file\\path\\to\\csv\\in\\zip'

presumably because can't reference csv within zip file absolute path. due reason?


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -