This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

how to match a search in a big data file  RSS feed

 
Ranch Hand
Posts: 93
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have to search a file by id and display all the information containing their names




 
Vani Sweety
Ranch Hand
Posts: 93
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a sample of the file


99918 | Pyrgulopsis bruneauensis | | scientific name |
199919 | Pyrgulopsis greggi | | scientific name |
199920 | Pyrgulopsis guiliani | | scientific name |
199921 | Pyrgulopsis intermedia | | scientific name |
199922 | Pyrgulopsis micrococcus | | scientific name |
199923 | Pyrgulopsis neritella | | scientific name |
199924 | Pyrgulopsis owensensis | | scientific name |
199925 | Pyrgulopsis pecosensis | | scientific name |
199926 | Pyrgulopsis peculiaris | | scientific name |
199927 | Pyrgulopsis robusta | | scientific name |
199928 | Pyrgulopsis stearnsiana | | scientific name |
199929 | Pyrgulopsis turbatrix | | scientific name |
199930 | Pyrgulopsis wongi | | scientific name |
199931 | Rhapinema | | scientific name |
199932 | Rhapinema dacryon | | scientific name |
199933 | symbiont of Haemaphysalis concinnae | | scientific name |
199934 | Andricus malpighii | | scientific name |
199935 | Andricus mitratus | | scientific name |
199936 | Andricus panteli | | scientific name |
199937 | Andricus quercusramuli | | scientific name |
199938 | Somatogyrus | | scientific name |
199939 | Somatogyrus sp. HSL-2002 | | scientific name |
199940 | Spilochlamys | | scientific name |
199941 | Spilochlamys gravis | | scientific name |
199942 | Stiobia | | scientific name |
199943 | Stiobia nana | | scientific name |
199944 | Cymbidium chloranthum | | scientific name |
199944 | Cymbidium chloranthum Lindl. | | authority |
199945 | Cymbidium finlaysonianum | | scientific name |
199945 | Cymbidium finlaysonianum Wall. ex Lindl. | | authority |
199946 | Austropeplea tomentosa | | scientific name |
199947 | Fossaria bulimoides | | scientific name |
199948 | Fossaria obrussa | | scientific name |
199949 | Lymnaea sp. EEAR-China-2002 | | scientific name |
199950 | Lymnaea sp. EEAR-Hawaii-2002 | | scientific name |
199951 | Lymnaea viridis | | scientific name |
199952 | Pettancylus | | scientific name |
199953 | Pettancylus sp. EEAR-2002 | | scientific name |
199954 | Radix luteola | | scientific name |
199956 | Radix sp. EEAR-Philippines-2002 | | scientific name |
199957 | Radix sp. EEAR-Canada-2002 | | scientific name |
199958 | Radix sp. EEAR-Romania-2002 | | scientific name |
199959 | Stagnicola bonnevillensis | | scientific name |
199960 | Stagnicola elrodi | | scientific name |
199961 | Stagnicola sp. EEAR-Montana-2002 | | scientific name |
199962 | Stagnicola sp. EEAR-Ukraine-2002 | | scientific name |
199963 | Monopterus sp. A TC-2002 | | scientific name |
199963 | Monopterus sp. A-TC-2002 | | synonym |
199964 | Monopterus sp. B TC-2002 | | scientific name |
199964 | Monopterus sp. B-TC-2002 | | synonym |
199965 | Monopterus sp. C TC-2002 | | scientific name |
199965 | Monopterus sp. C-TC-2002 | | synonym |
199967 |
 
Saloon Keeper
Posts: 5140
54
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a big data file, it can easily fit into memory. Is this the whole or just part of the data? Some of the id's have duplicates. What are you supposed to do with those cases? The last record is partial. Is this a cut-and-paste error or can the file contain partial records?
 
Vani Sweety
Ranch Hand
Posts: 93
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is just part of the file
i need to display the information for example if a enter an id it should display the scientific names
if id repeats meaning that it has more data that needs to be display for example the common names
 
Carey Brown
Saloon Keeper
Posts: 5140
54
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You need to call your method getBufferedReader(). Then in the while loop you need to call the reader's readLine() method. Then you need to call split() on the line and send the results to your 'data' variable. From there you can compare the input id with the string held in data[0], note, that for this to work you'll need to input the id as a String and not an int.

Hopefully this will nudge you along. Re-post your code when you get stuck at the next stage.
 
Marshal
Posts: 61713
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you get your hands on the buffered reader, you should probably use its lines method (Java8 only) to get a Stream<String>. Then you can use methods like anyMatch(s -> s.equals("Pseudomonas aeruginosa"))

Don't copy‑and‑paste that code
 
Vani Sweety
Ranch Hand
Posts: 93
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
infact i need to make a search by their id
the id might repeat in the file having different names
i am trying to do that as simple as possible
i have try to implement another coding but am getting problem with the method indexOF:
 
Vani Sweety
Ranch Hand
Posts: 93
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


the problem is that it is displaying all names containing "22"
whether is 22 itself or 3422
 
Campbell Ritchie
Marshal
Posts: 61713
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are already discussing the problem about 22; I think I shall merge the two threads together.
 
Campbell Ritchie
Marshal
Posts: 61713
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The merge doesn't seem to have worked. Please continue all discussion about 22 here (unless the merge appears later).
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!