Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • 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: 43027
76
  • 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 ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic