Questions tagged [tarfile]

either a tar archive file or a Python module used to handle tar archive files

The term "tar file" can refer to either an archive file created with the UNIX tar command (also called a tarball) or the Python tarfile module that is used to read, write, and manage these files.

Resources

Related Tags

231 questions
0
votes
1 answer

tarfile doesn't work for .gz files

I have a nested tarfile in the form of tarfile.tar.gz --tar1.gz --tar1.txt --tar2.gz --tar3.gz I wanted to write a little script in python to extract all tars breadth first in to the same order of folders i.e. tar1.txt should lie in…
abhipil
  • 164
  • 2
  • 13
0
votes
1 answer

python tarfile unpredictable error tarfile.ReadError: empty header

When opening a tar file with the python tarfile module like tarfile.open(path, mode='a') i get the error Traceback (most recent call last): File "/home/IPP-HGW/dboe/anaconda2/lib/python2.7/tarfile.py", line 1711, in open return…
0
votes
1 answer

How to read gz compressed files from tar

Let's say we have a tar file which in turn contains multiple gzip compressed files. I want to be able to read the contents of those gzip files without compressing either the tar file or the individual gzip files. I 'm trying to use tarfile module in…
Vineel
  • 1,630
  • 5
  • 26
  • 47
0
votes
1 answer

Trying to restrict regex match scope

Python newb here, please excuse the dumb question. I am trying to extract log data from inside of a group of gzipped files. The data spans multiple lines so I am trying to extract each file from its compressed tar file and read it as a single object…
Unpossible
  • 603
  • 6
  • 23
0
votes
1 answer

Python2.7: Untar files in parallel mode (with threading)

I'm learning Python threading and in the same time trying to improve my old untaring script. The main part of it looks like: import tarfile, os, threading def untar(fname, path): print "Untarring " + fname try: ut =…
Oddy
  • 13
  • 3
0
votes
1 answer

Python: how could I access tarfile.add()'s 'name' parameter in add()'s filter method?

I would like to filter subdirectories (skip them) while creating tar(gz) file with tarfile (python 3.4). Files on…
Balint
  • 45
  • 8
0
votes
3 answers

How to insert strings and slashes in a path?

I'm trying to extract tar.gz files which are situated in diffent files named srm01, srm02 and srm03. The file's name must be in input (a string) to run my code. I'm trying to do something like this : import tarfile import glob thirdBloc = 'srm01'…
Arij SEDIRI
  • 2,088
  • 7
  • 25
  • 43
0
votes
0 answers

python: how to give a input list from a file to tarfile?

Is there a parameter for giving input list from a list file to tar file? I known in cli "-T" parameter can do this, but tarfile.py has something like that? I use subprocess but i want to handle it without cli 'tar' command. Thank you.
F. Korhan
  • 1
  • 2
0
votes
1 answer

NameError while converting tar.gz to zip

I got the following code from my question on how to convert the tar.gz file to zip file. import tarfile, zipfile tarf = tarfile.open(name='sample.tar.gz', mode='r|gz' ) zipf = zipfile.ZipFile.open( name='myzip.zip', mode='a',…
Geet
  • 2,515
  • 2
  • 19
  • 42
0
votes
1 answer

Dumping JSON directly into a tarfile

I have a large list of dict objects. I would like to store this list in a tar file to exchange remotely. I have done that successfully by writing a json.dumps() string to a tarfile object opened in 'w:gz' mode. I am trying for a piped…
kingledion
  • 2,263
  • 3
  • 25
  • 39
0
votes
1 answer

Using tarfile library with special characters

I want to create tarfile with Turkish characters(like "ö") but I get an error. I'm using python 2.7 on Windows 8.1. Here is my code: # -*- coding: utf-8 -*- import tarfile import os import sys foldername = "klasör" foldername =…
Ayse
  • 43
  • 1
  • 5
0
votes
1 answer

Getting the md5 from .tar file

I have seen answers for this but didn't get the right way to do it. Our package has been created in .tar format by some other team. How can i get the checksum of the contents of the files in tar ball using Python? People have suggested to create…
0
votes
1 answer

Excluding directories from tarfile module

I am trying to tar the contents of a directory using the tarfile module. Say this directory, called 'A', has several subdirectories, 'a' and 'a1' etc... Is there a way to exclude these directories from the tarfile object when trying to add? For…
domsmiff
  • 57
  • 2
  • 6
0
votes
1 answer

Order of opening files when using tarfile.open() in Python

I have a simple question yet I didn't manage to find a lot of information about it or understand it very well. When I open a tarfile in python using the tarfile.open() method, how exactly are the files in the tarfile read? I have a tarfile with…
Georgi Nikolov
  • 113
  • 3
  • 11
0
votes
2 answers

python: tarfile extraction error IOError: [Errno 22] invalid mode ('wb') or filename

I'm extracting a file using tarfile. Unfortunately this compressed file came from a linux server, and contains several files that contain illegal Windows OS characters for files (':'). I'm using the below: extract =…
Derorrist
  • 2,753
  • 1
  • 17
  • 26