java - How can I extract specific terms from each string line? -
I have a serious problem in extracting words from each string line to be more specific, I have a CSV formatted file Which is not actually a CSV format (it saves all the positions in the [0] line only)
So, here is an example between thousands of string lines of string lines;
test.csv
line1: "31451 cid00531904415393353c8h14o3s2 beta-lipoic acid C 1 cs @ s [c @ hh] 1 cccccc (= hey)) o "
line 2:" 12232 COD 05374044 23439353 C 9 24 o3s2 saponin CCCC (= O) O "
Line 3:" 9048 CTD 42032 23241C3HO4O3S2 Berberin [C @ HH] 1CCCCC (= O) O "
I want to remove " beta-lipoic acid ", " saponin " and " berberine " Only 5 Located at the threshold. You can see that there are large spaces between words, so I said at the 5th position.
In this case, how can I remove positions located in the 5th position for each row?
One more thing;
The length of white space between each of six words is not always the same. Length can be one, two, three or four ... maybe ... something like this ...
Try another one:
import java.io.file; Import java.util.Scanner; Public class hallowld {// line per row column, where each column is separated by an arbitrary number / spacing or tab final fixed int COLS = 7; Public static zero main (string [] args) {System.out.println ("token:"); Try (Scanner Scanner = New Scanner (New File ("input.txt"). UseDelimiter ("\\ s +")) // // Current column-id int n = 0; string tmp = ""; stringbiller item = New stringbilder (); // Operating a stream (scanner.hasNext ()) {tmp = scanner.next (); N + = 1; // If we have reached the fifth column, take its contents And // add six columns, as we want the space to have different // expressions. Customize your name-layout Feel free to do so (n% COLS == 5) {item.setLength (0); item.append (tmp); Item.append (""); item.append (scanner.next ()); N + = 1; Println (item.toString ()); // Do some stuff with that expression // we found}}} hold (java.io.IOException e) {System.out.println (e.getMessage ());}}}
Comments
Post a Comment