python: use CSV reader with single file extracted from tarfile
问题 I am trying to use the Python CSV reader to read a CSV file that I extract from a .tar.gz file using Python's tarfile library. I have this: tarFile = tarfile.open(name=tarFileName, mode="r") for file in tarFile.getmembers(): tarredCSV = tarFile.extractfile(file) reader = csv.reader(tarredCSV) next(reader) # skip header for row in reader: if row[3] not in CSVRows.values(): CSVRows[row[3]] = row All the files in the tar file are all CSVs. I am getting an exception on the first file. I am