Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100208 > unrolled thread
| Started by | srinivas devaki <mr.eightnoteight@gmail.com> |
|---|---|
| First post | 2015-12-10 00:42 +0530 |
| Last post | 2015-12-10 00:42 +0530 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Reading lines of text from 7z compressed files in Python srinivas devaki <mr.eightnoteight@gmail.com> - 2015-12-10 00:42 +0530
| From | srinivas devaki <mr.eightnoteight@gmail.com> |
|---|---|
| Date | 2015-12-10 00:42 +0530 |
| Subject | Re: Reading lines of text from 7z compressed files in Python |
| Message-ID | <mailman.99.1449688408.12405.python-list@python.org> |
On Dec 9, 2015 3:07 PM, "Anmol Dalmia" <dalmia.anmol@gmail.com> wrote:
>
>
> I wish to use the native LZMA library of Python 3.4 for faster performance
> than any other third- party packages. Is it possible to do so?
>
you can check the source of lzma module main compression and decompression
algorithms were written in c. so obviously you will get faster performance.
In [21]: import _lzma
In [22]: _lzma.__file__
Out[22]:
'/home/eightnoteight/.anaconda3/envs/snakes3.4.3/lib/python3.4/lib-dynload/_
lzma.cpython-34m.so'
and regarding your problem, here's a simple example on how you can read
line by line of your compressed 7z text file.
import lzma
with lzma.open('test.7z', 'w') as lf:
lf.write(b'123\n'*1000)
with lzma.open('test.7z', 'r') as lf:
arr = list(lf)
print(len(arr))
print(set(arr))
print(arr[0])
print(arr[0].decode('utf-8'))
[gist] https://gist.github.com/38681cad88928b089abb
later you can even extract that test.7z with 7z command line client with
(7z x test.7z)
Back to top | Article view | comp.lang.python
csiph-web