• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

get the word by position

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

i have a flat file , in that i have date field , i know the row and column of this date my question is can i get this date by using this column number and row number in java

please help me out

thanks and regards

kumaraswamy adurthi
 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java on its own does not provide that type of capability. What you asking for is functionality of DBMS systems. You need to program yourself to read that row and columns.

If you use Oracle, there is a feature called external files where in you can map a flat file as table. So you can query it as any other table.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you know the structure of the file precisely, and since you know the row and column, it may be possible to calculate the offset of the date field from the beginning of the file. With that offset you can either use RandomAccessFile or FileInputStream.skip() to access that position directly.

If the fields have varying lengths, and are not padded to fixed length, then this is not possible.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If its a file with line breaks and delimiters (ex, csv) between column values, I think it will be possible to use a combination of iterating over rows using readLine() and iterating over columns using Scanner.next() or String.split() or Regex to achieve the purpose. However this may not be a good approach in case the file is very big.

If the file contains fixed width columns, then you can try using RandomAccessFile.seek() to take you to the appropriate value using some math.

If its a delimited file which is not too big, another option will be to read and populate a 2-dim String Array from the file and read directly using the co-ords.
[ July 04, 2006: Message edited by: John Calabasas ]
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic