Print the header
raquelsilva opened this issue · 6 comments
raquelsilva commented
Hello!
I need to print only the header of a .las file. How could I do it?
WarrenWeckesser commented
Hello @raquelsilva,
What do you mean by "print only the header"? Does that mean literally print everything in the file up to but not including the data section? That could be as simple as:
with open('filename.las', 'r') as f:
for line in f:
if line.lstrip().startswith('~A'):
break
print(line.rstrip())
raquelsilva commented
Thank you very much, Warren. Yes, I need to print everything except the
data.
I will test it and let you know if it's what I need.
Best regards,
Raquel
…On Wed, 25 Apr 2018, 00:57 Warren Weckesser, ***@***.***> wrote:
Hello @raquelsilva <https://github.com/raquelsilva>,
What do you mean by "print only the header"? Does that mean literally
print everything in the file up to but not including the data section? That
could be as simple as:
with open('filename.las', 'r') as f:
for line in f:
if line.lstrip().startswith('~A'):
break
print(line.rstrip())
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI7rtLGVkkDs2sFp9QYvhM272rbxHydRks5tr63tgaJpZM4TiO8B>
.
raquelsilva commented
This is almost what I need. Now, I need to save it in a parameter or in an
external file.
To save in an external file I've use the following code:
orig_stdout = sys.stdout
f = open('out.las', 'w')
sys.stdout = f
l.write(sys.stdout, version=2.0)
sys.stdout = orig_stdout
f.close()
But I don't know how I could save the print command to a parameter or file.
Raquel
2018-04-25 0:57 GMT+02:00 Warren Weckesser <notifications@github.com>:
… Hello @raquelsilva <https://github.com/raquelsilva>,
What do you mean by "print only the header"? Does that mean literally
print everything in the file up to but not including the data section? That
could be as simple as:
with open('filename.las', 'r') as f:
for line in f:
if line.lstrip().startswith('~A'):
break
print(line.rstrip())
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI7rtLGVkkDs2sFp9QYvhM272rbxHydRks5tr63tgaJpZM4TiO8B>
.
--
Raquel Theodoro
raquelsilva commented
I have other problem. Now, I need to append new data to the header. But
when I try to use the following command:
orig_stdout = sys.stdout
sys.stdout=open('out.las','a+')
print data_DT
The output is this:
'OPMD. up: OPERATION
MODE'
'QCRM. carregado por Bucheb: QC COMMENT'
'QCDT. 1999/01/26: QC DATE'
'QCCD. high: QC LEVEL'
'QCCO. UNKNOWN: QC COMPANY'
'QCST. final: QC STATUS'
'~Curve Information Block'
'#MNEM.UNIT API CODE No
Description'
'#========= ======== ==
==========='
'DEPT.M 00 001 00 00: 1 DEPTH'
'DT. : 2 Sonic
delta-T']
[[ 155.0396 nan]
[ 155.192 nan]
[ 155.3444 nan]
...,
[ 3028.694 nan]
[ 3028.8464 nan]
[ 3028.9988 nan]]
Both the header and the data are being printed as an array. The data is not
being printed fully. I would like to have the same output your code gives.
Thank you in advance for your cooperation.
Raquel
2018-04-25 5:35 GMT+02:00 Raquel Theodoro <ratheodoro@gmail.com>:
… Thank you very much, Warren. Yes, I need to print everything except the
data.
I will test it and let you know if it's what I need.
Best regards,
Raquel
On Wed, 25 Apr 2018, 00:57 Warren Weckesser, ***@***.***>
wrote:
> Hello @raquelsilva <https://github.com/raquelsilva>,
>
> What do you mean by "print only the header"? Does that mean literally
> print everything in the file up to but not including the data section? That
> could be as simple as:
>
> with open('filename.las', 'r') as f:
> for line in f:
> if line.lstrip().startswith('~A'):
> break
> print(line.rstrip())
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AI7rtLGVkkDs2sFp9QYvhM272rbxHydRks5tr63tgaJpZM4TiO8B>
> .
>
--
Raquel Theodoro
raquelsilva commented
I also need to edit the value of some items at the header.
Can I do this with this code?
2018-04-25 8:44 GMT+02:00 Raquel Theodoro <ratheodoro@gmail.com>:
… I have other problem. Now, I need to append new data to the header. But
when I try to use the following command:
orig_stdout = sys.stdout
sys.stdout=open('out.las','a+')
print data_DT
The output is this:
'OPMD. up: OPERATION
MODE'
'QCRM. carregado por Bucheb: QC COMMENT'
'QCDT. 1999/01/26: QC DATE'
'QCCD. high: QC LEVEL'
'QCCO. UNKNOWN: QC COMPANY'
'QCST. final: QC STATUS'
'~Curve Information Block'
'#MNEM.UNIT API CODE No
Description'
'#========= ======== ==
==========='
'DEPT.M 00 001 00 00: 1 DEPTH'
'DT. : 2 Sonic
delta-T']
[[ 155.0396 nan]
[ 155.192 nan]
[ 155.3444 nan]
...,
[ 3028.694 nan]
[ 3028.8464 nan]
[ 3028.9988 nan]]
Both the header and the data are being printed as an array. The data is
not being printed fully. I would like to have the same output your code
gives.
Thank you in advance for your cooperation.
Raquel
2018-04-25 5:35 GMT+02:00 Raquel Theodoro ***@***.***>:
> Thank you very much, Warren. Yes, I need to print everything except the
> data.
>
> I will test it and let you know if it's what I need.
>
> Best regards,
> Raquel
>
> On Wed, 25 Apr 2018, 00:57 Warren Weckesser, ***@***.***>
> wrote:
>
>> Hello @raquelsilva <https://github.com/raquelsilva>,
>>
>> What do you mean by "print only the header"? Does that mean literally
>> print everything in the file up to but not including the data section? That
>> could be as simple as:
>>
>> with open('filename.las', 'r') as f:
>> for line in f:
>> if line.lstrip().startswith('~A'):
>> break
>> print(line.rstrip())
>>
>> —
>> You are receiving this because you were mentioned.
>> Reply to this email directly, view it on GitHub
>> <#1 (comment)>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AI7rtLGVkkDs2sFp9QYvhM272rbxHydRks5tr63tgaJpZM4TiO8B>
>> .
>>
>
--
Raquel Theodoro
--
Raquel Theodoro
WarrenWeckesser commented
@raquelsilva I think this issue is in the same category as #2. It sounds like you need something with more capabilities than the simple reader provided by this package. I'm closing this issue, but I'll be thinking about possible future enhancements for the package.