reading columns of data
Please, help with input of doubles, ints and character in column layout
I am trying to port in java the following Fortran code:
Program Read
Implicit None
Integer, Parameter:: wp=Kind(1.0d0)
Integer::i,lenk,error
Character(len=40)::name
Integer, Allocatable::time(:)
Integer*8, Allocatable :: vol(:)
Character (len=4),Allocatable:: tick(:)
Real (wp),Allocatable :: po(:),ph(:),pl(:),p(:)
print *, 'enter file name'
read *, name
name ='/home/hpc1367/data/' // trim(name)
Open (2,file=name)
Do!!$ just to count the number of rows
Read(2,*, iostat = error)
If (error == -1) Exit
lenk = lenk + 1
Enddo
Print *, lenk
Rewind(2) !!$go back to beginning of file
Allocate(p(lenk),tick(lenk),time(lenk),po(lenk),ph(lenk),pl(lenk),vol(lenk))
Do i=1,lenk
Read (2, *) tick(i), time(i), po(i),ph(i),pl(i),p(i),vol(i)
Enddo
Close(2)
End Program Read
the file looks like:
AABC,20050103,14.2,14.2,14.2,14.2,590
AACC,20050103,21.53,21.65,21.3,21.35,51548
AACE,20050103,29.41,29.75,28.29,28.5,77257
AAME,20050103,3.07,3.07,3.01,3.07,7927
AANB,20050103,20,20.001,18.701,18.701,3803
AAON,20050103,16.5,16.99,14.8,15.01,97040
AAPL,20050103,32.39,32.555,31.3,31.645,24764860
AATK,20050103,2.35,2.35,2.15,2.2,140212
AAUK,20050103,23.75,23.88,23.25,23.301,125183
ABAX,20050103,14.98,14.98,14.05,14.05,125680

