Topic: open()/codecs.open()

I want to read a custom file (*.max) en pull some info out of it.
If I open the blahblah.max in notpad and copy-paste it into a variable in my code,
my regular expressions are working fine. But i can't just load it in.
I open the *.max file in notepad and save it as a txt file It doesn't work either.

errors i get when trying open(filename,"rU" and codec.open()):
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 4608: character maps to <undefined>


So any help is welcome.

I deleted the most part of the file and saved it as a txt file to attach it do you can see what i'm talking about.

Post's attachments

needtoopenfile.txt 17.72 kb, 2 downloads since 2012-01-24 

You don't have the permssions to download the attachments of this post.

Thumbs up

Re: open()/codecs.open()

Hello,
I've been looking around and found how to open the file, but there's a problem.

f = open('C:/Users\Jos/DAE/3D/animation/robot.max', "rbU")
>>> f.seek(-3000,2)
812104
>>> f.read(3000)
b'x\x00S\x00i\x00m\x00u\x00l\x00a\x00t\x00i\x00o\x00n\x00S\x00t\x00e\x00p\x00\x00\x00\x15\x00\x00\x00\x11\x00\x00\x00g\x00P\x00x\x00U\x00s\x00e\x00F\x00i\x00r\x00s\x00t\x00F\x00r\x00a\x00m\x00e\x00\x00\x00\x00\x00\x16\x00\x00\x00\x0f\x00\x00\x00g\x00P\x00x\x00O\x00n\x00L\x00a\x00s\x00t\x00F\x00r\x00a\x00m\x00e\x00\x00\x.....

but how do I read what's in?

match = re.search(pat,text)
TypeError: can't use a string pattern on a bytes-like object

gives me an error..

I'm a beginner with python, so I really don't know. I've searched for information to decode, but can't figure it out by myself..

example of the file when I open it with notepad:
ÆÃŠ  T×}>`  àc(Aœ0[  ó<:çµ=]? € 9 €
 
pA
HB      €!\ €0 Ã €  Iso2ObjArr    Iso2View   
CAT_UINum   
Iso2HidFlags    Iso2Lations    Iso2Hidden    Iso2Camera  @ “ €P  ` Ÿ [t { €`
  k €`
    main 
(I only need the text parts)

Thumbs up

Re: open()/codecs.open()

#!/usr/bin/env python
# coding: utf-8

import re
with open('file.txt', 'rb') as f:
    pcontent = ''.join(c for c in f.read() if c.isalnum() or c.isspace())
pcontent = re.sub(r'\s{3,}', '\n', pcontent)
print pcontent
[guest@localhost tests]$ ./t.py

F
o0Fd
A
F
o0Fd
A
F
p
0
1
9
d C
lL8 C  a
B
g
P
5
x
2w
H
bVGlIE
Jd
B
a
iEJ  D
c
c
F
F
Sh
kHE
EULB KR
Xh
ZJdH
sjE
54F8He
oar7
5zI
m
En9P
DTW
J
Qo
F
L1
P
P
P
P
P
P
eDJ
I2G
gm
M9t
tQr
xam
q
r
s
t
u
v
w
a
T
cA0
9
pA
HB
0
Iso2ObjArr
Iso2View
CATUINum
Iso2HidFlags
Iso2Lations
Iso2Hidden
Iso2Camera
P
t
k
main
majorversion
l
type
integer
default
animatable
minorversion
l
type
integer
default
animatable
T
A0
S c e n e
T o t a l s
E x t e r n a l
D e p e n d e n c i e s
O b j e c t s
I
M a t e r i a l s
U s e d
P l u g  I n s
R e n d e r
D a t a
3 d s
M a x
V e r s i o n
1 4  0 0
U n c o m p r e s s e d
B u i l d
1 4  2  0  3 7 5
0
S a v e d
A s
V e r s i o n
1 4  0 0
V e r t i c e s
3 0 5 0
F a c e s
3 1 7 5
O b j e c t s
4 7
S h a p e s
1 2
L i g h t s
0
C a m e r a s
0
H e l p e r s
1 4
S p a c e
W a r p s
0
T o t a l
7 3
P l a n e 0 0 7
u n d e r b o d y
C y l i n d e r 0 1 5
O b j e c t 0 0 2
r i g h t u p p e r l e g
P l a n e 0 0 5
C o n e 0 0 5
C y l i n d e r 0 2 0
T u b e 0 0 8
C y l i n d e r 0 2 4
L i n e 0 0 4
L i n e 0 0 5
L i n e 0 0 6
O b j e c t 0 0 6
r i g h t u n d e r l e g
C y l i n d e r 0 2 5
r i g h t f e e t
C o n e 0 0 8
O b j e c t 0 0 5
l e f t u p p e r l e g
P l a n e 0 0 6
C o n e 0 1 0
O b j e c t 0 0 8
T u b e 0 1 0
C y l i n d e r 0 2 9
C y l i n d e r 0 3 0
L i n e 0 1 0
L i n e 0 1 1
L i n e 0 1 2
l e f t u n d e r l e g
C y l i n d e r 0 3 1
l e f t f e e t
O b j e c t 0 0 9
C o n e 0 1 1
H o s e 0 0 1
u p p e r b o d y
E l l i p s e 0 0 1
T u b e 0 0 5
O b j e c t 0 0 1
h e a d
B o x 0 2 6
r i g h t u p p e r a r m
C y l i n d e r 0 1 6
T u b e 0 0 6
C y l i n d e r 0 1 9
S p h e r e 0 0 4
L i n e 0 0 3
L i n e 0 0 2
L i n e 0 0 1
C h a m f e r B o x 0 0 1
r i g h t u n d e r a r m
C y l i n d e r 0 1 8
P l a n e 0 0 4
a r m
O b j e c t 0 0 4
B o x 0 2 7
B o x 0 2 8
B o x 0 2 9
B o x 0 3 0
l e f t u p p e r a r m
T u b e 0 0 9
C y l i n d e r 0 2 6
C y l i n d e r 0 2 7
S p h e r e 0 0 5
C h a m f e r B o x 0 0 2
L i n e 0 0 7
L i n e 0 0 8
L i n e 0 0 9
C y l i n d e r 0 2 8
C o n e 0 0 9
l e f t a r m
H o s e 0 0 2
O b j e c t 0 0 7
0 2
D e f a u l t
v i e w p o r t m a n a g e r  g u p
m r m a t e r i a l a t t r i b s  g u p
0
c u s t a t t r i b c o n t a i n e r  d l o
r a y f x  d l u
s a m p l e r s  d l h
i n k n p a i n t  d l t
m t l  d l t
p r o s o u n d  d l c
c t r l  d l c
p r i m  d l o
e p o l y  d l o
b a s i c o p s  d l m
m o d s  d l m
s c s  d l o
k e r n e l  d l k
r e n d  d l r
a c a d b l o c k s  d l u
i n s t a n c e m g r  d l u
b i p e d  d l c
r e a c t o r  d l c
p a r a m e d i t o r  g u p
b i t m a p p r o x i e s  d l u
s t o r a g e a n d f i l t e r  b m s
s c e n e e f f e c t l o a d e r  d l u
U s e r
N a m e  J o s
C o m p u t e r
N a m e  O L D B O Y
R e n d e r
W i d t h  7 6 8
R e n d e r
H e i g h t  5 7 6
R e n d e r
A s p e c t  1  0 0
R e n d e r e r
C l a s s I D A  1
R e n d e r e r
C l a s s I D B  0
P
R e n d e r e r
N a m e  D e f a u l t
S c a n l i n e
R e n d e r e r
A n i m a t i o n
S t a r t  0
A n i m a t i o n
E n d  0
R e n d e r
F l a g s  3 2
S c e n e
F l a g s  4 0 6 4 8
R e n d e r E l e m e n t s  1
D
0
8
G e n e r a l
M e s h
T o t a l s
S c e n e
T o t a l s
E x t e r n a l
D e p e n d e n c i e s
O b j e c t s
I
M a t e r i a l s
U s e d
P l u g  I n s
R e n d e r
D a t a
3 d s
M a x
V e r s i o n
1 4  0 0
U n c o m p r e s s e d
B u i l d
1 4  2  0  3 7 5
0
S a v e d
A s
V e r s i o n
1 4  0 0
V e r t i c e s
3 0 5 0
F a c e s
3 1 7 5
O b j e c t s
4 7
S h a p e s
1 2
L i g h t s
0
C a m e r a s
0
H e l p e r s
1 4
S p a c e
W a r p s
0
T o t a l
7 3
P l a n e 0 0 7
u n d e r b o d y
C y l i n d e r 0 1 5
O b j e c t 0 0 2
r i g h t u p p e r l e g
P l a n e 0 0 5
C o n e 0 0 5
C y l i n d e r 0 2 0
T u b e 0 0 8
C y l i n d e r 0 2 4
L i n e 0 0 4
L i n e 0 0 5
L i n e 0 0 6
O b j e c t 0 0 6
r i g h t u n d e r l e g
C y l i n d e r 0 2 5
r i g h t f e e t
C o n e 0 0 8
O b j e c t 0 0 5
l e f t u p p e r l e g
P l a n e 0 0 6
C o n e 0 1 0
O b j e c t 0 0 8
T u b e 0 1 0
C y l i n d e r 0 2 9
C y l i n d e r 0 3 0
L i n e 0 1 0
L i n e 0 1 1
L i n e 0 1 2
l e f t u n d e r l e g
C y l i n d e r 0 3 1
l e f t f e e t
O b j e c t 0 0 9
C o n e 0 1 1
H o s e 0 0 1
u p p e r b o d y
E l l i p s e 0 0 1
T u b e 0 0 5
O b j e c t 0 0 1
h e a d
B o x 0 2 6
r i g h t u p p e r a r m
C y l i n d e r 0 1 6
T u b e 0 0 6
C y l i n d e r 0 1 9
S p h e r e 0 0 4
L i n e 0 0 3
L i n e 0 0 2
L i n e 0 0 1
C h a m f e r B o x 0 0 1
r i g h t u n d e r a r m
C y l i n d e r 0 1 8
P l a n e 0 0 4
a r m
O b j e c t 0 0 4
B o x 0 2 7
B o x 0 2 8
B o x 0 2 9
B o x 0 3 0
l e f t u p p e r a r m
T u b e 0 0 9
C y l i n d e r 0 2 6
C y l i n d e r 0 2 7
S p h e r e 0 0 5
C h a m f e r B o x 0 0 2
L i n e 0 0 7
L i n e 0 0 8
L i n e 0 0 9
C y l i n d e r 0 2 8
C o n e 0 0 9
l e f t a r m
H o s e 0 0 2
O b j e c t 0 0 7
0 2
D e f a u l t
v i e w p o r t m a n a g e r  g u p
m r m a t e r i a l a t t r i b s  g u p
0
c u s t a t t r i b c o n t a i n e r  d l o
r a y f x  d l u
s a m p l e r s  d l h
i n k n p a i n t  d l t
m t l  d l t
p r o s o u n d  d l c
c t r l  d l c
p r i m  d l o
e p o l y  d l o
b a s i c o p s  d l m
m o d s  d l m
s c s  d l o
k e r n e l  d l k
r e n d  d l r
a c a d b l o c k s  d l u
i n s t a n c e m g r  d l u
b i p e d  d l c
r e a c t o r  d l c
p a r a m e d i t o r  g u p
b i t m a p p r o x i e s  d l u
s t o r a g e a n d f i l t e r  b m s
s c e n e e f f e c t l o a d e r  d l u
U s e r
N a m e  J o s
C o m p u t e r
N a m e  O L D B O Y
R e n d e r
W i d t h  7 6 8
R e n d e r
H e i g h t  5 7 6
R e n d e r
A s p e c t  1  0 0
R e n d e r e r
C l a s s I D A  1
R e n d e r e r
C l a s s I D B  0
P
R e n d e r e r
N a m e  D e f a u l t
S c a n l i n e
R e n d e r e r
A n i m a t i o n
S t a r t  0
A n i m a t i o n
E n d  0
R e n d e r
F l a g s  3 2
S c e n e
F l a g s  4 0 6 4 8
R e n d e r E l e m e n t s  1
D
L
d
l
t
4
D
L
T
l i c e n s e
p x  p l u g i n  u n i t t y p e
p x  p l u g i n  u n i t s c a l e
p x  p l u g i n  v e r s i o n
p x  s d k  s k i n w i d t h
p x  r b  s o l v e r i t e r t i o n s
p x  s d k  s l e e p l i n e v e l
p x  s d k  s l e e p a n g v e l
p x  s d k  b o u n c e t h r e s h
p x  s d k  d y n a m i c f r i c t i o n s c a l i n g
p x  s d k  s t a t i c f r i c t i o n s c a l i n g
p x  s d k  m a x a n g v e l
p x  s d k  c c d  e p s i l o n
p x  s d k  s u b  s i m  s t e p s
p x  s d k  e n a b l e  g r a v i t y
p x  s d k  g r a v i t y x
p x  s d k  g r a v i t y y
p x  s d k  g r a v i t y z
g P x S i m u l a t i o n S t e p
g P x U s e F i r s t F r a m e
g P x O n L a s t F r a m e
g P x L o o p A n i m a t i o n
g P x G e o m e t r y S c a l e
g P x U s e G r o u n d
g P x U s e M u l t i T h r e a d
g P x U s e H a r d w a r e S c e n e
p x  s d k  c o n t i n u o u s  c d
g P x S l e e p T h r e s h o l d s A u t o m a t i c
g P x C C D M i n S p e e d A u t o m a t i c
g P x B o u n c e M i n S p e e d A u t o m a t i c
p x  s d k  c c d  m o t i o n  t h r e s h o l d
p x  r e s t o r e  o r i g i n a l  p o s e
s t u d e n t
B
z

[guest@localhost tests]$

Thumbs up

Re: open()/codecs.open()

wow thanx!
unfortunately the code you gave me gives me an error

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-4: truncated \UXXXXXXXX escape

I solved this problem, but get an anotherone

with open(r'C:\Users\Jos\Desktop\file.max', 'rbU') as f:
    pcontent = ''.join(c for c in f.read() if c.isalnum() or str(c).isspace())
pcontent = re.sub(r'\s{3,}', '\n', pcontent)
print( pcontent )

AttributeError: 'int' object has no attribute 'isalnum'

Im using python 3.2, is that the problem?

Last edited by Jos (January 26, 2012 06:23)

Thumbs up

Re: open()/codecs.open()

#!/usr/bin/env python3

import string
import re
with open('file.txt', 'r', encoding='latin1') as f:
    content = ''.join(c for c in f.read() if c in string.printable)
pcontent = re.sub('\s{3,}', '\n', content)
print(pcontent)
[guest@localhost tests]$ ./t.py

F
o:0Fd
^
A
=
F
o:0Fd
^
A
=
@F
? p
0
?1
`!\
@
 @
"
!<
[&<9
{d C
lL8 C  a
B
g
\P
,5
x
2w
H:
bVGlIE?
+|Jd
#
@
@
@?
@?
@  @
@B!=
@
@
@
@
@
@
@
@
@
@
@
@
@
@  @
@  @
@
@  ?
@
@
@
@
@
@
@
@
@
!
@
"
@
#
@
`{{a
_i\.E`J  D
c
@_@
c@
!
?"
#
$
%
&
F@'
F@(
@@)
@@*
+
,
-
.
?/
$S_h
kHE&
EULB KR
$X_h
ZJdH
s<j!E
54F8He
oar7
$5zI
{m'&
En9$P
DTW
+J
=+Qo
F
L1 -
P
P
P
P
P
P
eD~J.
I2G%
-/\
[gm
M[9~t
?tQr
xa_m
q
r
s
t
u
v
w
a*
T}>`
c(A0[
<:=]?
9
pA
HB
!\ 0
Iso2ObjArr
Iso2View
CAT_UINum
Iso2HidFlags
Iso2Lations
Iso2Hidden
Iso2Camera
@  P
`
[t  { `
k `
main
`
`
major_version
l  `
type
integer
default
animatable
`
minor_version
l  `
type
integer
default
animatable
T
:
?
?
?
A0
S c e n e
T o t a l s
,
E x t e r n a l
D e p e n d e n c i e s
O b j e c t s
I
M a t e r i a l s
U s e d
P l u g - I n s
R e n d e r
D a t a
|
.
3 d s
M a x
V e r s i o n :
1 4 , 0 0
U n c o m p r e s s e d
$
B u i l d :
1 4 . 2 . 0 . 3 7 5
0
S a v e d
A s
V e r s i o n :
1 4 , 0 0
V e r t i c e s :
3 0 5 0
F a c e s :
3 1 7 5
O b j e c t s :
4 7
S h a p e s :
1 2
L i g h t s :
0
C a m e r a s :
0
H e l p e r s :
1 4
S p a c e
W a r p s :
0
T o t a l :
7 3
P l a n e 0 0 7
u n d e r b o d y
C y l i n d e r 0 1 5
O b j e c t 0 0 2
r i g h t u p p e r l e g
P l a n e 0 0 5
C o n e 0 0 5
C y l i n d e r 0 2 0
T u b e 0 0 8
C y l i n d e r 0 2 4
L i n e 0 0 4
L i n e 0 0 5
L i n e 0 0 6
O b j e c t 0 0 6
r i g h t u n d e r l e g
C y l i n d e r 0 2 5
r i g h t f e e t
C o n e 0 0 8
O b j e c t 0 0 5
l e f t u p p e r l e g
P l a n e 0 0 6
C o n e 0 1 0
O b j e c t 0 0 8
T u b e 0 1 0
C y l i n d e r 0 2 9
C y l i n d e r 0 3 0
L i n e 0 1 0
L i n e 0 1 1
L i n e 0 1 2
l e f t u n d e r l e g
C y l i n d e r 0 3 1
l e f t f e e t
O b j e c t 0 0 9
C o n e 0 1 1
H o s e 0 0 1
u p p e r b o d y
E l l i p s e 0 0 1
T u b e 0 0 5
O b j e c t 0 0 1
h e a d
B o x 0 2 6
r i g h t u p p e r a r m
C y l i n d e r 0 1 6
T u b e 0 0 6
C y l i n d e r 0 1 9
S p h e r e 0 0 4
L i n e 0 0 3
L i n e 0 0 2
L i n e 0 0 1
C h a m f e r B o x 0 0 1
r i g h t u n d e r a r m
C y l i n d e r 0 1 8
P l a n e 0 0 4
a r m
O b j e c t 0 0 4
B o x 0 2 7
B o x 0 2 8
B o x 0 2 9
B o x 0 3 0
l e f t u p p e r a r m
T u b e 0 0 9
C y l i n d e r 0 2 6
C y l i n d e r 0 2 7
S p h e r e 0 0 5
C h a m f e r B o x 0 0 2
L i n e 0 0 7
L i n e 0 0 8
L i n e 0 0 9
C y l i n d e r 0 2 8
C o n e 0 0 9
l e f t a r m
H o s e 0 0 2
O b j e c t 0 0 7
0 2
-
D e f a u l t
(
v i e w p o r t m a n a g e r . g u p
,
m r m a t e r i a l a t t r i b s . g u p
0
c u s t a t t r i b c o n t a i n e r . d l o
r a y f x . d l u
s a m p l e r s . d l h
i n k n p a i n t . d l t
m t l . d l t
p r o s o u n d . d l c
c t r l . d l c
p r i m . d l o
e p o l y . d l o
b a s i c o p s . d l m
m o d s . d l m
s c s . d l o
k e r n e l . d l k
r e n d . d l r
a c a d b l o c k s . d l u
i n s t a n c e m g r . d l u
b i p e d . d l c
r e a c t o r . d l c
p a r a m e d i t o r . g u p
$
b i t m a p p r o x i e s . d l u
*
s t o r a g e a n d f i l t e r . b m s
,
s c e n e e f f e c t l o a d e r . d l u
U s e r
N a m e = J o s
*
C o m p u t e r
N a m e = O L D B O Y
"
R e n d e r
W i d t h = 7 6 8
$
R e n d e r
H e i g h t = 5 7 6
&
R e n d e r
A s p e c t = 1 , 0 0
(
R e n d e r e r
C l a s s I D A = 1
(
R e n d e r e r
C l a s s I D B = 0
P
R e n d e r e r
N a m e = D e f a u l t
S c a n l i n e
R e n d e r e r
$
A n i m a t i o n
S t a r t = 0
A n i m a t i o n
E n d = 0
R e n d e r
F l a g s = 3 2
$
S c e n e
F l a g s = 4 0 6 4 8
"
R e n d e r E l e m e n t s = 1
. +,D
. +,  |
0
8
@
G e n e r a l
M e s h
T o t a l s
S c e n e
T o t a l s
,
E x t e r n a l
D e p e n d e n c i e s
O b j e c t s
I
M a t e r i a l s
U s e d
P l u g - I n s
R e n d e r
D a t a
|
.
3 d s
M a x
V e r s i o n :
1 4 , 0 0
U n c o m p r e s s e d
$
B u i l d :
1 4 . 2 . 0 . 3 7 5
0
S a v e d
A s
V e r s i o n :
1 4 , 0 0
V e r t i c e s :
3 0 5 0
F a c e s :
3 1 7 5
O b j e c t s :
4 7
S h a p e s :
1 2
L i g h t s :
0
C a m e r a s :
0
H e l p e r s :
1 4
S p a c e
W a r p s :
0
T o t a l :
7 3
P l a n e 0 0 7
u n d e r b o d y
C y l i n d e r 0 1 5
O b j e c t 0 0 2
r i g h t u p p e r l e g
P l a n e 0 0 5
C o n e 0 0 5
C y l i n d e r 0 2 0
T u b e 0 0 8
C y l i n d e r 0 2 4
L i n e 0 0 4
L i n e 0 0 5
L i n e 0 0 6
O b j e c t 0 0 6
r i g h t u n d e r l e g
C y l i n d e r 0 2 5
r i g h t f e e t
C o n e 0 0 8
O b j e c t 0 0 5
l e f t u p p e r l e g
P l a n e 0 0 6
C o n e 0 1 0
O b j e c t 0 0 8
T u b e 0 1 0
C y l i n d e r 0 2 9
C y l i n d e r 0 3 0
L i n e 0 1 0
L i n e 0 1 1
L i n e 0 1 2
l e f t u n d e r l e g
C y l i n d e r 0 3 1
l e f t f e e t
O b j e c t 0 0 9
C o n e 0 1 1
H o s e 0 0 1
u p p e r b o d y
E l l i p s e 0 0 1
T u b e 0 0 5
O b j e c t 0 0 1
h e a d
B o x 0 2 6
r i g h t u p p e r a r m
C y l i n d e r 0 1 6
T u b e 0 0 6
C y l i n d e r 0 1 9
S p h e r e 0 0 4
L i n e 0 0 3
L i n e 0 0 2
L i n e 0 0 1
C h a m f e r B o x 0 0 1
r i g h t u n d e r a r m
C y l i n d e r 0 1 8
P l a n e 0 0 4
a r m
O b j e c t 0 0 4
B o x 0 2 7
B o x 0 2 8
B o x 0 2 9
B o x 0 3 0
l e f t u p p e r a r m
T u b e 0 0 9
C y l i n d e r 0 2 6
C y l i n d e r 0 2 7
S p h e r e 0 0 5
C h a m f e r B o x 0 0 2
L i n e 0 0 7
L i n e 0 0 8
L i n e 0 0 9
C y l i n d e r 0 2 8
C o n e 0 0 9
l e f t a r m
H o s e 0 0 2
O b j e c t 0 0 7
0 2
-
D e f a u l t
(
v i e w p o r t m a n a g e r . g u p
,
m r m a t e r i a l a t t r i b s . g u p
0
c u s t a t t r i b c o n t a i n e r . d l o
r a y f x . d l u
s a m p l e r s . d l h
i n k n p a i n t . d l t
m t l . d l t
p r o s o u n d . d l c
c t r l . d l c
p r i m . d l o
e p o l y . d l o
b a s i c o p s . d l m
m o d s . d l m
s c s . d l o
k e r n e l . d l k
r e n d . d l r
a c a d b l o c k s . d l u
i n s t a n c e m g r . d l u
b i p e d . d l c
r e a c t o r . d l c
p a r a m e d i t o r . g u p
$
b i t m a p p r o x i e s . d l u
*
s t o r a g e a n d f i l t e r . b m s
,
s c e n e e f f e c t l o a d e r . d l u
U s e r
N a m e = J o s
*
C o m p u t e r
N a m e = O L D B O Y
"
R e n d e r
W i d t h = 7 6 8
$
R e n d e r
H e i g h t = 5 7 6
&
R e n d e r
A s p e c t = 1 , 0 0
(
R e n d e r e r
C l a s s I D A = 1
(
R e n d e r e r
C l a s s I D B = 0
P
R e n d e r e r
N a m e = D e f a u l t
S c a n l i n e
R e n d e r e r
$
A n i m a t i o n
S t a r t = 0
A n i m a t i o n
E n d = 0
R e n d e r
F l a g s = 3 2
$
S c e n e
F l a g s = 4 0 6 4 8
"
R e n d e r E l e m e n t s = 1
\  #
<
D
L
d
l
t
|
$
,
4
<
D
L  !
T
l i c e n s e
p x _ p l u g i n _ u n i t t y p e
p x _ p l u g i n _ u n i t s c a l e
p x _ p l u g i n _ v e r s i o n
p x _ s d k _ s k i n w i d t h
p x _ r b _ s o l v e r i t e r t i o n s
p x _ s d k _ s l e e p l i n e v e l
p x _ s d k _ s l e e p a n g v e l
p x _ s d k _ b o u n c e t h r e s h
p x _ s d k _ d y n a m i c f r i c t i o n s c a l i n g
p x _ s d k _ s t a t i c f r i c t i o n s c a l i n g
p x _ s d k _ m a x a n g v e l
p x _ s d k _ c c d _ e p s i l o n
p x _ s d k _ s u b _ s i m _ s t e p s
p x _ s d k _ e n a b l e _ g r a v i t y
p x _ s d k _ g r a v i t y x
p x _ s d k _ g r a v i t y y
p x _ s d k _ g r a v i t y z
g P x S i m u l a t i o n S t e p
g P x U s e F i r s t F r a m e
g P x O n L a s t F r a m e
g P x L o o p A n i m a t i o n
g P x G e o m e t r y S c a l e
g P x U s e G r o u n d
g P x U s e M u l t i T h r e a d
g P x U s e H a r d w a r e S c e n e
p x _ s d k _ c o n t i n u o u s _ c d
g P x S l e e p T h r e s h o l d s A u t o m a t i c
g P x C C D M i n S p e e d A u t o m a t i c
g P x B o u n c e M i n S p e e d A u t o m a t i c
p x _ s d k _ c c d _ m o t i o n _ t h r e s h o l d
!
p x _ r e s t o r e _ o r i g i n a l _ p o s e
s t u d e n t
?
B!=
?
@
z
->
?

[guest@localhost tests]$

Thumbs up

Re: open()/codecs.open()

wow thank you!
it works fine! i'm working now on the regular expressions.

I just have one problem. Because max file ar pretty large I want to start read at almost the end of the fil (there's mt information),
I tried end seek. but now I get an error

seek(-10000,2)
io.UnsupportedOperation: can't do nonzero end-relative seeks

Is there something to solve this?
I tried this

b = os.path.getsize(r'C:\Users\Jos\Desktop\gameart.max')
            f.seek(b-10000)

It seems to work, but donno of this is the best method?
tank you for all yout help!!

Last edited by Jos (January 26, 2012 14:45)

Thumbs up

Re: open()/codecs.open()

>>> import os.path
>>> fname = '/etc/profile'
>>> with open(fname, encoding='utf-8') as f:
...     n = f.seek(int(os.path.getsize(fname) / 2))
...     print(f.read())
... 

    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi

HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "$PS1" ]; then
            . $i
        else
            . $i >/dev/null 2>&1
        fi
    fi
done

unset i
unset pathmunge

>>>

Thumbs up

Re: open()/codecs.open()

Thanx for fast reply.
If I just divide the size with 2 It prints like 40 pages.
But I want the first 100 lines en the last 100 lines (dont know exactly)
I can handle your first 5 lines of code, but after i'm lost.

can you gave me a little explanation? (mail, logname, user, hostname? do I need this?)
I'm very greatfull for all your help

Thumbs up

Re: open()/codecs.open()

Jos wrote:

I can handle your first 5 lines of code, but after i'm lost.

other lines are from the file

Jos wrote:

But I want the first 100 lines en the last 100 lines (dont know exactly)

you cannot handle lines, because you are working with binary data

Last edited by struct.h (January 28, 2012 01:24)

Thumbs up