parsing - How to work with and how to parse a text file with mixed content in Java -


i need advice on how go processing text file in java. have file, have lines on top data, , table. example, in beginning of file have totals like:

cars purchased = 1890 cars returned = 130 

then there table, contains car ids:

id#1 =127974 id#2 =212445 

and table:

table begin:  customer id | price paid | car brand#1 | car brand#2 |  car brand#4   id#1 id#2 

i have

  1. print out cars purchased value, cars returned value, array car ids and
  2. create tabular set based on last table.

can please explain me logic on how go in java? i not asking code, guidelines/steps/pseudocode. can't understand how can separate text file 3 chunks , have input reader concentrate on 1 of 3 @ time. example, car ids can similar client ids in table, can 1 not let input reader read unnecessary information?

another thing - if read file, parts of tab-separated , other parts not, how figure out begin reading tab-separated part only?

if beginning of file has cars purchased = 1890 , have return 1890 only, have scan through entire file? search words "cars purchased" , somehow access value?

then, when have put of in tabular set, how know each entry match relevant entry original file?

also, not working single file, whatever file of same type provided, assuming key names car id, cars purchased, cars returned same.

i need understanding how 1 process file this.

"i can't understand how can separate text file 3 chunks , have input reader concentrate on 1 of 3 @ time."

because don't know data starts , stops, need read text file sequentially, , start paying attention data when section want. in pseudocode:

while (you haven't gotten text marks start of section) {   read line;   throw line away; } while (you haven't reached text marks end of section) {   read line;   line; } 

you'll notice after we're done our section, don't keep reading -- there's no need, unless there's want further on down.

should read in whole thing , store it, or read multiple times deal each section? that's design decision, based on lots of factors -- speed of reading, how memory have vs how data take up, etc.

how know each entry match tabular data? depends on how store it. read bit on objects , data structures ideas. beginners, arrays easy handle.


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -