LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2006, 06:31 AM   #16
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148

Quote:
Originally Posted by dimah
Don't work!
Doesn't really help those trying to help you does it...

What doesn't work? Does it fail to compile? Does it run but fail to read? What doesn't work?

Here is the code segment from the Qt web site documentation for QT version 3.1
Code:
QFile f(fileName);
f.open(IO_ReadOnly);
char buffer[256];
int l = 256;
l=f.readBlock(buffer,l);
 
Old 06-07-2006, 10:44 AM   #17
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
SEG-Y files are huge, in general. and you dont read them 4 bytes at a time. It is least efficient way of doing it. You have to read them in binary mode, so you open the file in binary mode.

Read 3200 bytes and assign it to a datastructure ccalled EBCDICHeader, then read 400 bytes and allocate it to BinaryHeader.
From Binaryheader, get length of seismic trace(No. Of samples * sample size + 240 bytes for traceheader). Keep reading this chunk of bytes until all the data is done.

You cant do it in a simple 5 line program. Large data structures are involved.

Panyam Prabhakar
 
Old 06-08-2006, 03:38 AM   #18
dimah
LQ Newbie
 
Registered: May 2006
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks a lot, but i really did't understand how to get normal data from this crazy symbols.
For example, this code (i think) must read 4 bytes into buffon;
So i see only that crazy delirium!
////////////////////////////////////////////////////
for (int i=0;i<1000;i++){
char buffon[1024];
int k=4;
l=f.readBlock(buffon,k);
cout << buffon << endl;}
////////////////////////////////////////////////////
What's wrong?
 
Old 06-08-2006, 11:01 AM   #19
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
The data is in binary format. Thats it. You have to convert it to int or float or what-ever-it-is and then "cout" it. Unless ofcourse your data is ascii characters.

If you are trying to print first 3200 bytes of the SEG-Y file, they are characters alright, but they are in EBCDIC format. So you just cant print them.

If you want to print your EBCDIC header, try this

Code:
dd if=colda1.sgy of=colda1.ebc ibs=3200 count=1 conv=ascii
I am not really sure, I have understood your problem. You have to give more details and also explain what you are trying to achieve with your code.

ppanyam
 
Old 06-08-2006, 11:09 PM   #20
dimah
LQ Newbie
 
Registered: May 2006
Posts: 28

Original Poster
Rep: Reputation: 15
ppanyam,
Am i right that after 3600 bytes there are the numerals?
And i need to find 21 byte.
After that i need to find last byte.
Of course i need to take the normal numerals (12 or 324) but not that abra-cadabra.
I think that's all i need to.

So my 21 byte will be 1st (conditionally) and i need to get the last numeral.
I home my English is enough to explain what i want.
Thanks for you participation.
 
Old 06-10-2006, 11:14 AM   #21
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
Dear dilmah

I am on a vacation now. I will send a perl script to do it when I get back to work next week. You are right in assumption that there are numbers after 3600 bytes. I presume you are looking for inline or xline number. But I have not understood what you meant by
Quote:
and i need to get the last numeral.

ppanyam
 
Old 06-11-2006, 06:32 AM   #22
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
I assume you are able to read your 4 bytes from 21 to 24 th locations. Then you can use this and try to print your number

/* read 4 bytes into char buffer[4]; */
fread(.....;
/* add this to your code */
union u{
char ch[4];
int lno;
}

union u myU;
strcpy(myU.ch,buffer);
printf("myInteger is %d.\n",myU.lno);

..

I havent run this, but it should work.


ppanyam
 
Old 06-15-2006, 11:28 PM   #23
dimah
LQ Newbie
 
Registered: May 2006
Posts: 28

Original Poster
Rep: Reputation: 15
I ran it and got that number:
1077952576
What is that number?
 
Old 06-16-2006, 12:30 AM   #24
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
Can you run the following command and send the output (zipped) to me by email?

dd if=yourdata.sgy of=topdata.dat ibs=64000 count=4

I have to look into the header before I can comment what that number is. Looks like there is a Byte order issue. Maybe not

ppanyam
 
Old 06-16-2006, 01:41 AM   #25
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
Sorry... My email id is ppanyam@gmail.com
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PLZ, PLZ help - need some info kevmif Linux - General 9 12-17-2007 06:12 AM
plz plz help me regarding route mapping nedian123 Programming 1 07-13-2004 08:17 AM
plz plz solve my route mapping problem nedian123 Linux - Networking 1 07-12-2004 09:41 PM
plz, help me (plz realy ) h4ng4m3 Linux - General 10 08-18-2003 06:07 AM
redhat problems plz plz help sap666 Linux - Newbie 5 07-30-2003 10:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration